-
Notifications
You must be signed in to change notification settings - Fork 0
/
parsereport.py
36 lines (29 loc) · 928 Bytes
/
parsereport.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys
import collections
def main():
file_name = "fullreport.csv"
if len(sys.argv) > 1:
file_name = sys.argv[1]
games = collections.Counter()
won = collections.Counter()
lengths = collections.Counter()
with open(file_name, 'r') as f:
for line in f:
# ignore sim; lines
if 'sim;bs;i;N' in line:
continue
fields = line.split(';')
key = ';'.join(fields[:6])
games[key] += 1
if fields[6] == 'true':
won[key] += 1
lengths[key] += int(fields[7])
out_name = "parsedreport.csv"
if len(sys.argv) > 2:
out_name = sys.argv[2]
with open(out_name, 'w') as f:
f.write('sim;bs;i;N;p;q;runs;won;sumlengths;\n')
for k in games:
f.write('{};{};{};{};\n'.format(k,games[k],won[k],lengths[k]))
if __name__ == '__main__':
main()