In [1]:
import json
import pandas as pd

In [2]:
dataset = pd.read_csv('EVA_restoswithlocationsANDfixes.csv')
dataset.head(n=5)


Out[2]:
city name street tags zipcode full_address latlon missing
0 Neerijse Biesbemd Kamstraat 33 ['Approved by EVA', 'EVA voordeel', 'Veganvrie... 3040 Kamstraat 33 3040 Neerijse (50.8127340562564, 4.622892881244533) False
1 Antwerpen Falafel Shami Hoogstraat 47 ['Snack', '100% vegetarisch', 'Approved by EVA... 2000 Hoogstraat 47 2000 Antwerpen (51.21912277399896, 4.39791278664577) False
2 Antwerpen Falafel Tof Hoogstraat 32 ['Eethuis', 'Snack', '100% vegetarisch', 'Appr... 2000 Hoogstraat 32 2000 Antwerpen (51.219967595445304, 4.398256839416387) False
3 Antwerpen Falafeltof Hoogstraat 32 ['Snack', '100% vegetarisch', 'Approved by EVA... 2000 Hoogstraat 32 2000 Antwerpen (51.219967595445304, 4.398256839416387) False
4 Deurle Markies de Salade Xavier de Cocklaan 69 ['Eethuis', '100% plantaardig', '100% vegetari... 9831 Xavier de Cocklaan 69 9831 Deurle (51.00079815695149, 3.614998033550879) False

In [5]:
dataset[dataset['missing'] == True].shape


Out[5]:
(0, 8)

In [11]:
interesting_cols = ['city', 'name', 'street', 'tags', 'zipcode', 'latlon']
dataset = dataset[interesting_cols]

In [13]:
dataset.head(n=3)


Out[13]:
city name street tags zipcode latlon
0 Neerijse Biesbemd Kamstraat 33 ['Approved by EVA', 'EVA voordeel', 'Veganvrie... 3040 (50.8127340562564, 4.622892881244533)
1 Antwerpen Falafel Shami Hoogstraat 47 ['Snack', '100% vegetarisch', 'Approved by EVA... 2000 (51.21912277399896, 4.39791278664577)
2 Antwerpen Falafel Tof Hoogstraat 32 ['Eethuis', 'Snack', '100% vegetarisch', 'Appr... 2000 (51.219967595445304, 4.398256839416387)

In [18]:
dataset['lat'] = dataset['latlon'].apply(lambda l: l[1:len(l)-1].split(',')[0])
dataset['lon'] = dataset['latlon'].apply(lambda l: l[1:len(l)-1].split(',')[1])

In [20]:
interesting_cols = ['city', 'name', 'street', 'tags', 'zipcode', 'lat', 'lon']
dataset = dataset[interesting_cols]

In [24]:
tempfile = 'testjsonrestos.json'
dataset.to_json(tempfile, orient='records')

In [26]:
data = []
with open(tempfile) as f:
    for line in f:
        data.append(json.loads(line))

In [46]:
records = data[0]

parsedRecs = []

for rec in records:
    testObj = {
        'city'   : rec['city'],
        'lat'    : float(rec['lat']),
        'lon'    : float(rec['lon']),
        'name'   : rec['name'],
        'street' : rec['street'],
        'tags'   : eval(rec['tags']),
        'zip'    : rec['zipcode']
    }
    
    parsedRecs.append(testObj)

In [49]:
with open('restodata.json', 'w') as outfile:
    json.dump(parsedRecs, outfile, sort_keys=True, indent=4, separators=(',', ':'))

In [42]:
testobj = {}
testobj['city']


['Approved by EVA', 'EVA voordeel', 'Veganvriendelijk']

In [ ]:


In [ ]:


In [ ]:


In [ ]:
json.dumps(, sort_keys=True, indent=2, separators=(',', ': '))