Skip to content

Instantly share code, notes, and snippets.

@tomrittervg
Created May 4, 2022 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomrittervg/ad615aeb6ea11178ed7d3d530aba951c to your computer and use it in GitHub Desktop.
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.
# 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