Last active
October 28, 2015 03:47
-
-
Save chrisseldo/7745f46f6c3360f1f5db to your computer and use it in GitHub Desktop.
CSV Read/Parse -- Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'CSV' | |
read_csv = CSV.read(file_name) | |
headers = read_csv.shift.map {|i| i.to_s } | |
string_data = read_csv.map {|row| row.map {|cell| cell.to_s } } | |
array_of_hashes = string_data.map {|row| Hash[*headers.zip(row).flatten] } | |
(tag_header, tag_data) = [headers, array_of_hashes] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment