Last active
January 11, 2021 10:37
-
-
Save phearnot/75460551e67b35cdcbfc9055006d93ca to your computer and use it in GitHub Desktop.
This file contains 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
from datetime import datetime | |
import fileinput, re | |
MESSAGE_REGEX = re.compile(r'(^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3}) .+ - ((New height|Imported|Opening import).+)$') | |
first_ts = 0 | |
def process(line): | |
global first_ts | |
result = MESSAGE_REGEX.match(line) | |
if result: | |
message_ts = int(datetime.fromisoformat(result[1].replace(',', '.')).timestamp() * 1000) | |
if first_ts == 0: | |
first_ts = message_ts | |
else: | |
offset = message_ts - first_ts | |
message = result[2].replace('New height: ', '') | |
print(f'{offset},{message}') | |
for line in fileinput.input(): | |
process(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment