Created
August 11, 2020 21:55
-
-
Save sadjad/5469e8a5e236897e8fb909feb1f4b27e to your computer and use it in GitHub Desktop.
Turn gg timing logs to csv
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
#!/usr/bin/env python3 | |
import os | |
import sys | |
datadir = sys.argv[1] | |
data_points = [] | |
headers = [] | |
for logfile in os.listdir(datadir): | |
path = os.path.join(datadir, logfile) | |
with open(path, "r") as log: | |
timelog = [] | |
for line in log: | |
if not timelog: | |
timelog += [('started', int(line))] | |
else: | |
timelog += [(line.split()[0], int(line.split()[1]))] | |
point = [x[1] for x in timelog] | |
data_points += [point] | |
if not headers: | |
headers = [x[0] for x in timelog] | |
data_points.sort(key=lambda x: x[0]) | |
T0 = data_points[0][0] | |
for d in data_points: | |
d[0] = d[0] - T0 | |
d.append(sum(d[:-1])) | |
#print", ".join(['"timing_data" using %d t "%s"' % (i+1,x) for x, i in enumerate(headers) ]) | |
print("\t".join(["#"] + headers)) | |
for i, d in enumerate(data_points): | |
print(" ".join([str(i)] + [str(x) for x in d])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment