Importing a huge csv data file and using a header to access columns using Ruby
1 answer
FasterCSV (also available as CSV in Ruby 1.9 standard library ) should be able to do the trick. You can use column headers to access row data:
require 'fastercsv'
FasterCSV.foreach(csv_file, {:headers => true, :return_headers => false, :header_converters => :symbol, :converters => :all} ) do |row|
puts row[:some_column_header] # Would be "Some Column Header" in the csv file.
end
+7
source to share