I have to read a massive csv with about 40.000 entries with dates and values. I did that :
TreeMap<LocalDateTime,Double> fi = new TreeMap<LocalDateTime,Double>();
CSVReader reader = new CSVReader(new FileReader(path),';');
String [] nextLine;
while ((nextLine = reader.readNext()) != null) {
fi.put(LocalDateTime.parse (nextLine[0],DateTimeFormatter.ofPattern ("uuuu-MM-dd HH:mm")),Double.valueOf(nextLine[1]));
}
reader.close();
Reading from the file is really fast but the parsing into a LocalDateTime
is really slow, it takes about 9 minutes to complete. Any idea to do it faster?
Some sample lines from my CSV file:
2015-01-01 15:30;3
2015-01-01 15:45;5
2015-01-01 16:00;5
2015-01-01 16:15;3
2015-01-01 16:30;4
2015-01-01 16:45;5
2015-01-01 17:00;4
2015-01-01 17:15;3
2015-01-01 17:30;5
2015-01-01 17:45;4
2015-01-01 18:00;4