-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat_data.py
More file actions
33 lines (31 loc) · 843 Bytes
/
Copy pathformat_data.py
File metadata and controls
33 lines (31 loc) · 843 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
27
28
29
30
31
32
33
import json
output_file = 'data_formatted.json'
res = {'rows': []}
with open('data.json') as f:
data = json.load(f)['values']
for d in data:
name = d[5]
address = d[6]
city = d[8]
state = d[9]
instructions = d[10]
needs = d[11]
accepts_opened = d[12]
latitude = d[13]
try:
longitude = d[14]
except Exception:
longitude = ''
res['rows'].append({
'name': name,
'address': address,
'city': city,
'state': state,
'instructions': instructions,
'needs': needs,
'accepts_opened': accepts_opened,
'latitude': latitude,
'longitude': longitude
})
with open(output_file, 'w') as outfile:
json.dump(res, outfile)