Created
November 5, 2014 19:09
-
-
Save openfirmware/5987821b75dfc862639a to your computer and use it in GitHub Desktop.
Osmosis replag output converter
This file contains 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 -KU | |
# Convert output from osmosis to CSV for spreadsheets. | |
# Usage: ./convert.rb output | |
file = ARGV[0] | |
def parse(line) | |
matches = line.match(/^\[([^\]]+)\] \d+ start import from seq-nr (\d+), replag is (\d+) day\(s\) and (\d+) hour\(s\)$/) | |
{ | |
date: matches[1], | |
sequence: matches[2], | |
days: matches[3], | |
hours: matches[4] | |
} | |
end | |
IO.foreach(file) do |x| | |
result = parse(x) | |
puts [result[:date], 6, result[:sequence], result[:days], result[:hours]].join(',') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment