forked from od-ms/converter-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfahrradverleihe.py
45 lines (40 loc) · 1.24 KB
/
fahrradverleihe.py
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
34
35
36
37
38
39
40
41
42
43
44
45
# coding=utf-8
import json
import csv
from urllib.request import urlopen
import config as cfg
url = cfg.fahrradverleihe_url
outfile = 'data/fahrradverleihe.csv'
print("Data url:", url)
f = urlopen(url)
myfile = f.read()
#print(myfile)
data = json.loads(myfile)
#cityName "Billerbeck"
#email "..."
#hasDelivery false
#hasEbikes false
#id 34
#latitude 51.978301
#longitude 7.295661
#name "..."
#phone "..."
#street "Holthauser Strasse 3"
#website "..."
#zip "48727"
with open(outfile, mode='w') as csv_file:
fieldnames = ['name', 'street', 'zip', 'latitude', 'longitude', 'hasEbikes', 'hasDelivery']
writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
writer.writeheader()
for verleih in data['data']:
if (verleih['cityName'] == "Münster") and verleih["isPrivate"] == False:
del verleih["email"]
del verleih["cityName"]
del verleih["additionalInfo"]
del verleih["phone"]
del verleih["website"]
del verleih["isPrivate"]
del verleih["thumbnailUrl"]
del verleih["id"]
print('Name: ' + verleih['name'])
writer.writerow(verleih)