Skip to content

Instantly share code, notes, and snippets.

@rjollet
Created September 23, 2016 14:32
Show Gist options
  • Save rjollet/fc5c007e3ceec1cec4328a291553155f to your computer and use it in GitHub Desktop.
Save rjollet/fc5c007e3ceec1cec4328a291553155f to your computer and use it in GitHub Desktop.
require 'yaml'
require 'csv'
def hashs_to_array(hashs)
array = []
hashs.each do |hash|
array << hash.keys if array == []
array << hash.values
end
array
end
hashs = YAML.load(File.read(ARGV[0]))
array = hashs_to_array hashs
File.open(ARGV[1], 'w') do |file|
file.puts array.map(&:to_csv)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment