In [1]:
import json
import pandas as pd
In [2]:
dataset = pd.read_csv('EVA_restoswithlocationsANDfixes.csv')
dataset.head(n=5)
Out[2]:
In [5]:
dataset[dataset['missing'] == True].shape
Out[5]:
In [11]:
interesting_cols = ['city', 'name', 'street', 'tags', 'zipcode', 'latlon']
dataset = dataset[interesting_cols]
In [13]:
dataset.head(n=3)
Out[13]:
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']
In [ ]:
In [ ]:
In [ ]:
In [ ]:
json.dumps(, sort_keys=True, indent=2, separators=(',', ': '))