You're suggesting to use
.foreach instead of
.each for parsing large CSV files. Could you elaborate why this is better?
Ruslan Hassonov the approach with
.each will load all records into memory and then allow you to access them - this can crash your application if the file is big. From the other side,
.foreach goes through every line of the file without loading it into memory at once. It's similar to
find_each method in Rails when you deal with many records.