My application lets user to upload csv file with maximum of 50MB. I wanted to show the user the preview of the uploaded file. Can I read only the first 5 lines of csv? I am currently using CSV.read function, obviously this will read the entire file and is slow.
how to read first 5 lines of csv file using built in ruby csv
3.2k views Asked by Yakitate At
2
CSV#foreach
returns an enumerable, so just callEnumerable#take
on it: