Created
August 29, 2016 16:52
-
-
Save X0nic/4971619cacd5b9503232736ccce4c237 to your computer and use it in GitHub Desktop.
Convert a csv to json
This file contains hidden or 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
#! /usr/bin/env ruby | |
require 'csv' | |
require 'json' | |
csv = CSV.parse(File.read(file_name).scrub, headers: true) | |
hash = csv.map{ |row| { code: row["Classification Code"], description: row["Classification Code Description English"] } } | |
json = hash.to_json | |
File.write(new_file_name, json) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment