Created
August 8, 2016 05:17
-
-
Save holysugar/aaa8f602d9676b8d34f8db48fb093149 to your computer and use it in GitHub Desktop.
from ltsv to csv converter
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'csv' | |
firstline = true | |
io = $stdout | |
while line = ARGF.gets | |
data = line.chomp.split(/\t/).map{|item| item.split(/:/,2) }.to_h | |
if firstline | |
headers = data.keys | |
io.puts headers.to_csv | |
firstline = false | |
end | |
io.puts data.values_at(*headers).to_csv | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment