Created
November 27, 2017 17:23
-
-
Save oyiptong/1a7ebf24314bd6580612a760103d8ee1 to your computer and use it in GitHub Desktop.
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 | |
require 'csv' | |
require 'json' | |
if ARGV.length == 0 | |
puts "needs an argument. #{ARGV.length}" | |
exit(1) | |
end | |
rows =[] | |
file_data = File.read(ARGV[0]) | |
CSV.new(file_data, col_sep: '{', headers: true, quote_char: '"').each do |row| | |
rows << row.to_hash | |
end | |
puts "output is:\n#{JSON.pretty_generate(rows)}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment