code_junkie

Importing a huge csv data file and using the header to access columns using Ruby

Nov 13th, 2011
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. require 'fastercsv'
  2. FasterCSV.foreach(csv_file, {:headers => true, :return_headers => false, :header_converters => :symbol, :converters => :all} ) do |row|
  3. puts row[:some_column_header] # Would be "Some Column Header" in the csv file.
  4. end
Add Comment
Please, Sign In to add comment