Open ArsenyClean opened 5 years ago
You are reading lines in memory for no reason withIOUtils.readLines(getClass().getClassLoader().getResourceAsStream("test.csv"));
. Let the parser extract individual rows for you. Also this will break if your test.csv
file has fields that contain one or more line separators.
I never ran a performance analysis on parseLine(String);
but I'll take a look. Thank you for letting me know it's not performing as fast as it should.
Hi! I wrote a little test, using openCsv parser, that parse 200mb file for 5.5 sec. when the univocity Csv parser parse the same file about 24.2 sec. Can it be truth?
this is a test
` public class CsvCompare { @Test public void compareTest() { List lines = null;
try {
lines = IOUtils.readLines(getClass().getClassLoader().getResourceAsStream("test.csv"));
} catch (IOException e) {
throw new RuntimeException(e);
}
Parser openCsvParser = new Parser() {
CSVParser csvParser = new CSVParser(';');
public String[] parseLine(String line) {
try {
return csvParser.parseLine(line);
} catch (Exception e) {
e.printStackTrace();
errorLinesCounter++;
return new String[0];
}
}
};
} `
This test will failed
I cant explain for my own how can it be
Maybe i dont set some special settings?