Last active
September 26, 2016 02:25
-
-
Save dspp779/7a8585e767ec29731025c67ba0ef2c11 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
require 'csv' | |
require 'yaml' | |
def read_tsv(filepath) | |
table = CSV.read(filepath, col_sep: "\t", headers: true) | |
table.map(&:to_h) | |
end | |
if ARGV.size == 2 | |
data = read_tsv ARGV[0] | |
File.open(ARGV[1], 'w') { |file| file.write data.to_yaml } | |
else | |
STDERR.puts 'usage: ruby tsv_to_yml.rb path/to/tsv path/to/yml' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment