source: tmcsimulator/trunk/src/tmcsim/client/ATMSrenumber.py @ 178

Revision 178, 1.1 KB checked in by jdalbey, 9 years ago (diff)

ATMSrenumber.py added. A crude python script for renumbering times in an atmsBatchEvents file.

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    t = (2009, 2, 17, 0, mincount, 0, 1, 0, 0)
21    t = time.mktime(t)
22    print time.strftime("%H:%M:%S", time.gmtime(t)), str
23
24    # read a line and output with :30 secs
25    str = raw_input("");
26    t = (2009, 2, 17, 0, mincount, 30, 1, 0, 0)
27    t = time.mktime(t)
28    print time.strftime("%H:%M:%S", time.gmtime(t)), str
29    # increment the minute
30    mincount += 1;
31
Note: See TracBrowser for help on using the repository browser.