source: tmcsimulator/trunk/Scenarios/ATMSrenumber.py @ 417

Revision 417, 1.6 KB checked in by jdalbey, 7 years ago (diff)

Move ATMSrenumber.py to scripts folder

Line 
1#!/usr/bin/python
2# A crude script to prepend clock times to each line of input
3# Usage Scenario:  You've prepared an atmsBatchEvents.txt file
4#   with times for an actual scenario, and you want to try it
5#   out in the simulator without having to wait for hours.
6#   Run this script, redirecting your file to stdin.
7#   Copy and paste output to a new file, use unix 'cut'
8#   E.g.:    cut -d' ' -f1,2,4- abc.txt
9#   to remove the third column of original times,
10#   use vim to make any other global edits needed.
11#   Example Input:  405 00:02:30 N ....
12#           Output: 01:00:30 405 00:02:30 N ....
13import time
14
15mincount = 0;
16# Loop forever. (Better would be loop til EOF)
17while True:
18    # read a line and output with :00 secs
19    str = raw_input("");
20    if str[0] != '#':
21        fields = str.split()
22        t = (2009, 2, 17, 0, mincount, 0, 1, 0, 0)
23        t = time.mktime(t)
24#        print fields[0], time.strftime("%H:%M:%S", time.gmtime(t)), fields[2], "\t", fields[3], "\t", fields[4], "\t", fields[5]
25        print fields[0], time.strftime("%H:%M:%S", time.gmtime(t)),
26        print (%4s"% (fields[2])), 
27        print " ", fields[3], " ", (" %5s"%(fields[4])), "\t", fields[5]
28    else:
29        print str
30
31    # read a line and output with :30 secs
32    str = raw_input("");
33    if str[0] != '#':
34        fields = str.split()
35        t = (2009, 2, 17, 0, mincount, 30, 1, 0, 0)
36        t = time.mktime(t)
37        print fields[0], time.strftime("%H:%M:%S", time.gmtime(t)),
38        print (%4s"% (fields[2])), 
39        print " ", fields[3], " ", (" %5s"%(fields[4])), "\t", fields[5]
40    else:
41        print str
42
43    # increment the minute
44    mincount += 1;
45
Note: See TracBrowser for help on using the repository browser.