Last active
July 27, 2018 08:08
-
-
Save rhopp/f4b5af26567e44cb90ddd6d2cef9d493 to your computer and use it in GitHub Desktop.
Parse cr warlogs
This file contains hidden or 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
import json | |
class Participant: | |
wars = 0 | |
battles = 0 | |
wins = 0 | |
didntPlayWar = 0 | |
p={} | |
with open("/home/rhopp/temp/warlog.json", "r") as read_file: | |
data = json.load(read_file) | |
warcount=0 | |
for battle in data: | |
warcount+=1 | |
for participant in battle["participants"]: | |
if participant["name"] not in p: | |
p[participant["name"]] = Participant() | |
p[participant["name"]].wars+=1 | |
p[participant["name"]].battles+=participant["battlesPlayed"] | |
p[participant["name"]].wins+=participant["wins"] | |
if participant["battlesPlayed"] == 0: | |
p[participant["name"]].didntPlayWar+=1 | |
print("war count: "+str(warcount)) | |
for key, value in p.items(): | |
print("{},{},{},{},{}".format(key.encode('utf-8'),value.wars, value.battles, value.wins, value.didntPlayWar)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment