Skip to content

Instantly share code, notes, and snippets.

@rkachowski
Created May 17, 2013 09:35
Show Gist options
  • Save rkachowski/5598038 to your computer and use it in GitHub Desktop.
Save rkachowski/5598038 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'csv'
require 'json'
csv_data = CSV.read ARGV[0]
headings = csv_data[0].compact
result = []
csv_data[1..-1].each do |row|
result << Hash[headings.zip row]
end
f = File.open("#{ARGV[0]}.json","w+")
f << result.to_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment