Skip to content

Instantly share code, notes, and snippets.

@hirakujira
Last active September 28, 2015 07:41
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/1cbb97a444e73d850916 to your computer and use it in GitHub Desktop.
Save hirakujira/1cbb97a444e73d850916 to your computer and use it in GitHub Desktop.
require 'yaml'
lines = File.read(ARGV[0]).split("\n")
header = lines[0].split("\t")
lines.delete(lines[0])
hashes = []
lines.each do |line|
values = line.split("\t")
hash = Hash.new {}
header.each_index do |index|
hash[header[index]] = values[index]
end
hashes << hash
end
hashes = hashes.to_yaml
File.write(ARGV[1], hashes, mode: 'w')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment