Created
January 29, 2014 20:25
-
-
Save Slackwise/8696251 to your computer and use it in GitHub Desktop.
Converts a list of .csv files to .json files.
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
#!/usr/bin/env ruby | |
# | |
# Converts a list of .csv files to .json files. | |
require 'csv' | |
require 'json' | |
require 'pathname' | |
ARGV.each do |filename| | |
csv_file = Pathname.new(filename) | |
File.open(csv_file.basename.sub(/\.csv$/, '.json'), 'w') do |json_file| | |
json_file.write(CSV.read(csv_file).to_json) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment