I have csv file (600 MB) and 20 millions rows.
I need to read all this data, create list of java objects out of it, and calculate some metrics on objects field, such as average, median, max , total sum and other statistics. What is the best way of doing it in Java?
I tried simple .forEach loop and it took a while (20 min) to iterate over it .

**UPDATE:**
I user BufferReader to read the data and converting the csv file into List of Objects of some Java class. It's pretty fast.
 It's stuck for 20 minutes in **forEach** loop, where I trying to iterate over those 20 millions List of objects and divide them into 3 lists, depending on the values in the current object.
So basically,I iterate over whole list once, and I have if/else condition, where I check whether or not certain field in the objects equals to "X","Y" or "Z", and depending on the answer, separating those 20 mlns records into 3 lists.

Then, for those 3 lists I need to calculate different statistics: such as median, average, total sum etc