Skip first line while reading CSV file in Java

前端 未结 8 1598
别跟我提以往
别跟我提以往 2021-02-15 00:27

I am writing a parser code to read a .csv file and parse it to XML. This is the code I have and it works, except I would like it to skip the first line in the file. So I decided

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-15 00:54

    I am rather confused by your code, your have the lineMap and you also have fw (whatever that is). Which one are you using? You say you want to skip the first line, but you don't

    if (firstLine == true) {
       firstLine = false;
       continue;
    }
    

    I would also suggest using a library like CSVReader which I belive even has a property ignoreFirstLine

    http://opencsv.sourceforge.net/apidocs/au/com/bytecode/opencsv/CSVReader.html

提交回复
热议问题