Last active
September 23, 2016 14:32
-
-
Save rjollet/f1219dfc4d02235a5886687bec0308ae 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 'yaml' | |
require 'csv' | |
def array_to_hashs(array) | |
keys = array[0] | |
data = array[1..-1] | |
data.map { |values| Hash[keys.zip(values)] } | |
end | |
array = CSV.read(ARGV[0], col_sep: "\t") | |
hashs = array_to_hashs array | |
File.open(ARGV[1], 'w') do |file| | |
file.puts hashs.to_yaml | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment