Skip to content

Instantly share code, notes, and snippets.

@hirakujira
Last active September 28, 2015 07:40
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 hirakujira/0576c92003190692f9dc to your computer and use it in GitHub Desktop.
Save hirakujira/0576c92003190692f9dc to your computer and use it in GitHub Desktop.
require 'yaml'
def generate_line(items)
line = ''
items.each_with_index do |item, index|
line += item
line += "\t" if index < items.length - 1
end
line += "\n"
line
end
yaml_file = File.read(ARGV[0])
hashes = YAML::load(yaml_file)
header = hashes[0].keys
result = generate_line(header)
hashes.each { |item| result += generate_line(item.values) }
File.write(ARGV[1], result, mode: 'w')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment