CSV::Reader.parse(File.open('file.csv')){|row| puts row}
or
CSV::Reader.parse("some, content\nanother, content"){|row| puts row}
and
FasterCSV.parse(File.open('file.csv')){|row| puts row}
or
FasterCSV.parse("some, content\nanother, content"){|row| puts row}
are equivalent.
But
FasterCSV.read('filename')
accepts the file name as a parameter and reads and analyzes data from the file, however you discard the contents of the file when you pass data in the parameter
@parsed_file = FasterCSV.parse(params[:dump][:file])
@parsed_file.each do |row|
puts row
# and do some operations
end
should work fine.
source
share