#!/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(""); t = (2009, 2, 17, 0, mincount, 0, 1, 0, 0) t = time.mktime(t) print time.strftime("%H:%M:%S", time.gmtime(t)), str # read a line and output with :30 secs str = raw_input(""); t = (2009, 2, 17, 0, mincount, 30, 1, 0, 0) t = time.mktime(t) print time.strftime("%H:%M:%S", time.gmtime(t)), str # increment the minute mincount += 1;