Here is the code that counts the number of lines in a file. It works with BufferedReader
and is fine. No problem . In total there are over 25,000,000 rows
BufferedReader br = new BufferedReader(new FileReader("C:\\...test.csv"));
int lineNbr = 0;
while(br.readLine() != null) {
lineNbr++;
if (lineNbr%1000000==0) {
System.out.println(lineNbr);
}
}
br.close();
System.exit(0);
Here is a similar code with SuperCSV . It throws out of memory
after line 11,000,000
CsvListReader reader = new CsvListReader(new FileReader("C:\\... test.csv"), CsvPreference.EXCEL_PREFERENCE );
List<String> row = reader.read();
row = reader.read();
lineNbr = 0;
while (reader.read() != null) {
lineNbr++;
if (lineNbr%1000000==0) {
System.out.println(lineNbr);
}
}
reader.close();
System.exit(0);
What am i doing wrong? How to correctly read a file with SuperCSV ?