forked from theonlydude/RandomMetroidSolver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_stats.py
executable file
·61 lines (56 loc) · 2.06 KB
/
get_stats.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/python
from rom import RomLoader
from sys import argv
if __name__ == "__main__":
firstLogs = argv[1:]
itemNames = []
areaCounts = {}
areaNames = []
locCounts = {}
locNames = []
for log in firstLogs:
with open(log, 'r') as logFile:
lines = logFile.readlines()
lines = [l.strip() for l in lines]
for i in range(1, len(lines)): # skip header
line = lines[i]
fields = line.split(';')
item, loc, area = fields[0], fields[1], fields[2]
if loc not in locNames:
locNames.append(loc)
if area not in areaNames:
areaNames.append(area)
if item not in itemNames:
itemNames.append(item)
if item not in locCounts:
locCounts[item] = {}
if item not in areaCounts:
areaCounts[item] = {}
if area not in areaCounts[item]:
areaCounts[item][area] = 0
if loc not in locCounts[item]:
locCounts[item][loc] = 0
areaCounts[item][area] += 1
locCounts[item][loc] += 1
outFileName = 'area_stats.csv'
with open(outFileName, 'w') as outFile:
outFile.write("ITEM;{}\n".format(';'.join(sorted(areaNames))))
for item in sorted(itemNames):
outFile.write(item)
for area in sorted(areaNames):
c = 0
if area in areaCounts[item]:
c = areaCounts[item][area]
outFile.write(';' + str(c))
outFile.write('\n')
outFileName = 'loc_stats.csv'
with open(outFileName, 'w') as outFile:
outFile.write("LOCATION;{}\n".format(';'.join(sorted(itemNames))))
for locName in sorted(locNames):
outFile.write(locName + ";")
for itemName in sorted(itemNames):
c = 0
if locName in locCounts[itemName]:
c = locCounts[itemName][locName]
outFile.write(str(c) + ';')
outFile.write('\n')