Skip to content

Instantly share code, notes, and snippets.

@dspp779
Last active September 26, 2016 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dspp779/993e71217e66e3cf26d0096a0c85ec66 to your computer and use it in GitHub Desktop.
Save dspp779/993e71217e66e3cf26d0096a0c85ec66 to your computer and use it in GitHub Desktop.
require 'yaml'
require 'csv'
if ARGV.size == 2
data = YAML.load_file(ARGV[0])
CSV.open(ARGV[1], 'wb', col_sep: '\t') do |csv|
csv << data.first.keys
data.to_a.each { |item| csv << item.values }
end
else
STDERR.puts 'usage: ruby yml_to_tsv.rb path/to/yml path/to/tsv'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment