Created
July 4, 2017 22:42
-
-
Save saliksyed/b628e4aec088df91ffa49b233b9bc6f5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Wed Jul 5 00:19:18 2017 | |
@author: saliksyed | |
""" | |
import json | |
routes = json.loads(open("routes.json").read()) | |
country_to_country_code = json.loads(open("country_name_to_country_code.json").read()) | |
populations = json.loads(open("population_by_country_code.json").read()) | |
country_code_to_feature = {} | |
for country in routes: | |
if country in country_to_country_code: | |
code = country_to_country_code[country] | |
to_amount = sum(routes[country]["to"].values()) | |
from_amount = sum(routes[country]["from"].values()) | |
population = populations[code] | |
country_code_to_feature[code] = [to_amount, from_amount, population] | |
print country_code_to_feature |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment