Created
May 4, 2022 16:25
-
-
Save tomrittervg/ad615aeb6ea11178ed7d3d530aba951c to your computer and use it in GitHub Desktop.
Script to rewrite the timestamps in a TC job log to be relative so you can look easily for the jump and go to the line offset.
This file contains hidden or 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
# preprocess with `cut -d "]" -f 1` | |
import dateutil | |
from dateutil import parser | |
origin = None | |
f1 = open("2-2", "r") | |
f2 = open("2-2-1", "w") | |
for l in f1: | |
if not l.strip(): | |
f2.write("\n") | |
continue | |
parts = l.split(" ") | |
if len(parts) != 2: | |
f2.write("\n") | |
continue | |
if origin == None: | |
origin = dateutil.parser.parse(parts[1]) | |
f2.write("0\n") | |
continue | |
new = dateutil.parser.parse(parts[1]) | |
diff = new - origin | |
output = str(diff) + "\n" | |
f2.write(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment