forked from legis-graph/legis-graph
-
Notifications
You must be signed in to change notification settings - Fork 1
/
parse_committees.py
36 lines (28 loc) · 1023 Bytes
/
parse_committees.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
import csv
import yaml
OUTPUT_COLUMNS = [
'type',
'name',
'url',
'thomasID',
'jurisdiction',
]
def load_committees(kind):
if kind not in ['current', 'historical']:
raise Exception('Committee type must be either current or historical')
inpath = 'data/congress-legislators/committees-{}.yaml'.format(kind)
with open(inpath, 'r') as f:
current = yaml.load(f)
outpath = 'outputs/committees-{}.csv'.format(kind)
with open(outpath, 'w') as f:
writer = csv.DictWriter(f, OUTPUT_COLUMNS, extrasaction='ignore')
writer.writeheader()
for committee in current:
record = {}
record['type'] = committee.get('type', '')
record['name'] = committee.get('name', '')
record['url'] = committee.get('url', '')
record['thomasID'] = committee.get('thomas_id', '')
record['jurisdiction'] = committee.get('jurisdiction', '')
writer.writerow(record)
load_committees('current')