Skip to content

Instantly share code, notes, and snippets.

@ryotarai
Last active August 29, 2015 14:11
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 ryotarai/328ce5d2d13d2c6e81f1 to your computer and use it in GitHub Desktop.
Save ryotarai/328ce5d2d13d2c6e81f1 to your computer and use it in GitHub Desktop.
data = []
columns = []
ARGF.each_line do |line|
data << Hash[line.split("\t").map do |kv|
k, v = kv.split(':', 2)
columns << k unless columns.include?(k)
[k, v]
end]
end
puts columns.join("\t")
data.each do |datum|
puts(columns.map do |column|
datum[column]
end.join("\t"))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment