/ Published in: Ruby
To be improved to work with fasterCSV
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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] }