Revision: 65944
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 12, 2014 19:57 by legrandkay
Initial Code
require 'csv' csv_data = CSV.read 'data.csv' headers = csv_data.shift.map {|i| i.to_s } string_data = csv_data.map {|row| row.map {|cell| cell.to_s } } array_of_hashes = string_data.map {|row| Hash[*headers.zip(row).flatten] }
Initial URL
Initial Description
To be improved to work with fasterCSV
Initial Title
Turn CSV With Headers Into Array Of Hashes
Initial Tags
array, ruby, csv
Initial Language
Ruby