#!/usr/bin/python
# A crude script to prepend clock times to each line of input
# Usage Scenario:  You've prepared an atmsBatchEvents.txt file
#   with times for an actual scenario, and you want to try it
#   out in the simulator without having to wait for hours.
#   Run this script, redirecting your file to stdin.
#   Copy and paste output to a new file, use unix 'cut'
#   E.g.:    cut -d' ' -f1,2,4- abc.txt 
#   to remove the third column of original times,
#   use vim to make any other global edits needed.
#   Example Input:  405 00:02:30 N ....
#           Output: 01:00:30 405 00:02:30 N ....
import time

mincount = 0;
# Loop forever. (Better would be loop til EOF)
while True:
    # read a line and output with :00 secs
    str = raw_input("");
    if str[0] != '#':
        fields = str.split()
        t = (2009, 2, 17, 0, mincount, 0, 1, 0, 0)
        t = time.mktime(t)
#        print fields[0], time.strftime("%H:%M:%S", time.gmtime(t)), fields[2], "\t", fields[3], "\t", fields[4], "\t", fields[5]
        print fields[0], time.strftime("%H:%M:%S", time.gmtime(t)),
        print ("  %4s"% (fields[2])), 
        print " ", fields[3], " ", (" %5s"%(fields[4])), "\t", fields[5]
    else:
        print str

    # read a line and output with :30 secs
    str = raw_input("");
    if str[0] != '#':
        fields = str.split()
        t = (2009, 2, 17, 0, mincount, 30, 1, 0, 0)
        t = time.mktime(t)
        print fields[0], time.strftime("%H:%M:%S", time.gmtime(t)),
        print ("  %4s"% (fields[2])), 
        print " ", fields[3], " ", (" %5s"%(fields[4])), "\t", fields[5]
    else:
        print str

    # increment the minute
    mincount += 1;

