Skip to content

Instantly share code, notes, and snippets.

@rabidaudio
Created January 13, 2016 17:57
Show Gist options
  • Save rabidaudio/96ecad99f28dad3c9aef to your computer and use it in GitHub Desktop.
Save rabidaudio/96ecad99f28dad3c9aef to your computer and use it in GitHub Desktop.
CSV rows to objects
reqire 'csv'
csv = CSV.parse(File.read('input.csv'))
headers = csv.shift
objects = csv.map { |row| Hash[headers.zip(row)] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment