import json, pandas as pd, matplotlib.pyplot as plt
%matplotlib inline
data2a=json.loads(file('data2a.json','r').read())
g={}
for i in data2a['cities']:
g[i]=data2a['cities'][i]['count']
Fro=json.loads(file('F_ro.json','r').read())
f1={}
f3={}
for i in Fro:
if i['country'] not in f1:f1[i['country']]=0
f1[i['country']]+=i[u'heti j\xe1ratsz\xe1m']
if i['country'] not in f3:f3[i['country']]=0
f3[i['country']]+=i[u'heti j\xe1ratsz\xe1m']
Fhu=json.loads(file('F_hu.json','r').read())
f2={}
for i in Fhu:
if i['country'] not in f2:f2[i['country']]=0
f2[i['country']]+=i[u'heti j\xe1ratsz\xe1m']
if i['country'] not in f3:f3[i['country']]=0
f3[i['country']]+=i[u'heti j\xe1ratsz\xe1m']
hnames=json.loads(file('hnames.json','r').read())
d=[]
for f in f3:
if f not in {"India","Hong Kong"}:
if f in g:
print f, f3[f],g[f]
d.append({"country":f,u'heti j\xe1ratsz\xe1m':f3[f],u"diaszpóra":g[f],"hcountry":hnames[f]})
elif f=='Czechia':
print f,f3[f],g['Czech Republic']
d.append({"country":f,u'heti j\xe1ratsz\xe1m':f3[f],u"diaszpóra":g['Czech Republic'],"hcountry":hnames['Czech Republic']})
else: print '### ERROR ###',f
Turkey 66.5 13 Qatar 24.0 2 Italy 261.5 612 Lebanon 2.0 2 Malta 4.0 7 France 92.0 110 Georgia 2.0 1 Slovakia 2.0 38 Ireland 26.0 40 Norway 11.0 41 Israel 54.1 29 ### ERROR ### Belarus Algeria 2.0 2 ### ERROR ### Iceland Czechia 26.2 18 ### ERROR ### Jordan Belgium 77.5 61 Germany 346.7 1109 Spain 109.8 284 Ukraine 9.5 2 Netherlands 76.5 56 Denmark 19.5 122 Poland 55.0 7 Finland 15.0 7 Moldova 27.5 3 Sweden 25.0 103 ### ERROR ### Latvia Switzerland 44.0 140 Russia 26.5 5 Bulgaria 16.5 4 Romania 389.1 23421 Portugal 10.5 11 Egypt 5.0 5 United Arab Emirates 21.0 17 Serbia 14.5 22 ### ERROR ### Azerbaijan United Kingdom 263.2 743 Austria 78.0 210 China 1.5 3 Greece 37.5 34 Hungary 16.5 2723 Cyprus 11.5 27
file("diasp.json",'w').write(json.dumps(d))
d=[]
for f in f1:
if f not in "India":
if f in g:
d.append({"country":f,u'heti j\xe1ratsz\xe1m':f1[f],u"diaszpóra":g[f],"hcountry":hnames[f]})
elif f=='Czechia':
d.append({"country":f,u'heti j\xe1ratsz\xe1m':f1[f],u"diaszpóra":g['Czech Republic'],"hcountry":hnames['Czech Republic']})
file("diasp_ro.json",'w').write(json.dumps(d))
d=[]
for f in f2:
if f not in "Hong Kong":
if f in g:
d.append({"country":f,u'heti j\xe1ratsz\xe1m':f2[f],u"diaszpóra":g[f],"hcountry":hnames[f]})
elif f=='Czechia':
d.append({"country":f,u'heti j\xe1ratsz\xe1m':f2[f],u"diaszpóra":g['Czech Republic'],"hcountry":hnames['Czech Republic']})
file("diasp_hu.json",'w').write(json.dumps(d))