-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathadddata.py
More file actions
26 lines (21 loc) · 816 Bytes
/
adddata.py
File metadata and controls
26 lines (21 loc) · 816 Bytes
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
# -*- coding: utf-8 -*-
import csv, geonamescache
gc = geonamescache.GeonamesCache()
countryinfo = gc.get_countries()
def add(data, years):
"""Add tansparency and google user requests data to given dict for given years."""
with open('google-user-data-requests.csv', 'rb') as f:
r = csv.reader(f)
headings = r.next()
for row in r:
year = row[0].split('/')[-1]
if year not in years: continue
iso3 = countryinfo[row[2]]['iso3']
data[year][iso3]['userrequests'] = int(row[3])
with open('scrape_aid_transparency_2010.csv', 'rb') as f:
r = csv.reader(f)
headings = r.next()
for row in r:
iso3 = row[0]
if '' != iso3:
data['2010'][iso3]['aidtransparency'] = int(row[2])