Created
July 31, 2017 23:37
-
-
Save nneonneo/6d660af2c1f288a8c1319ea4b1b5f857 to your computer and use it in GitHub Desktop.
Munge scores for DEF CON 25 CTF
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
import csv | |
import json | |
with open('scores.csv') as f: | |
rows = [(int(row['id']), json.loads(row['payload'])) for row in csv.DictReader(f)] | |
rows.sort() | |
with open('scores_clean.csv', 'w') as outf: | |
csvf = csv.writer(outf) | |
team_names = [s['display_name'].encode('utf8') for s in sorted(rows[0][1], key=lambda s: s['id'])] | |
csvf.writerow(['round_no'] + team_names) | |
for roundno, payload in rows: | |
csvf.writerow([str(roundno)] + [s['score'] for s in sorted(payload, key=lambda s: s['id'])]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment