Skip to content

Instantly share code, notes, and snippets.

@nneonneo
Created July 31, 2017 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nneonneo/6d660af2c1f288a8c1319ea4b1b5f857 to your computer and use it in GitHub Desktop.
Save nneonneo/6d660af2c1f288a8c1319ea4b1b5f857 to your computer and use it in GitHub Desktop.
Munge scores for DEF CON 25 CTF
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