aboutsummaryrefslogtreecommitdiffstats
path: root/bin/parse_cord19_csv.py
blob: 536e5d38f6b98e33b7af1675d8b80097e4dcdf7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env python3

import sys
import csv
import json

CSVFILE = sys.argv[1]

with open(CSVFILE, newline='') as csvfile:
    reader = csv.DictReader(csvfile)
    for row in reader:
        row = dict(row)
        row['mag_id'] = row.pop('Microsoft Academic Paper ID')
        row['who_covidence_id'] = row.pop('WHO #Covidence').replace('#', '')
        print(json.dumps(row, sort_keys=True))