Skip to content

Instantly share code, notes, and snippets.

@maurcs
Forked from digitalscientists/gist:108159
Created May 7, 2009 16:38
Show Gist options
  • Save maurcs/108198 to your computer and use it in GitHub Desktop.
Save maurcs/108198 to your computer and use it in GitHub Desktop.
Uses ruby's built in CSV Reader which will find " escaped columns
require 'csv'
file = "db/commission_junction/2087028_18584_20080827.csv"
rows = CSV::Reader.parse(File.open(file)).to_a
cols = rows.shift
collection = rows.collect do |row|
Hash[*cols.zip(row).flatten]
end
puts collection.first.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment