Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import csv
- soubor = open('gardens.json', encoding='utf-8')
- data = soubor.read()
- gardens = json.loads(data)
- writer = csv.writer(open("gardens.csv", 'w', newline='', encoding='utf-8'))
- writer.writerow(['latitude','longitude','id','name','address','district','url','restaurace','wc','misto','mhd','sport','brusle','cesty','provoz','kolo','hriste','parking','doba'])
- for g in gardens['features']:
- latitude = g['geometry']['coordinates'][1]
- longitude = g['geometry']['coordinates'][0]
- parkid = g['properties']['id']
- name = g['properties']['name']
- address = g['properties']['address']
- district = g['properties']['district']
- url = g['properties']['url']
- items = g['properties']['properties']
- restaurace = None
- for i in items:
- v = i['id']
- if v == 'restaurace':
- restaurace = i['value']
- if v == 'wc':
- wc = i['value']
- if v == 'misto':
- misto = i['value']
- if v == 'mhd':
- mhd = i['value']
- if v == 'sport':
- sport = i['value']
- if v == 'brusle':
- brusle = i['value']
- if v == 'cesty':
- cesty = i['value']
- if v == 'provoz':
- provoz = i['value']
- if v == 'kolo':
- kolo = i['value']
- if v == 'hriste':
- hriste = i['value']
- if v == 'parking':
- parking = i['value']
- if v == 'doba':
- doba = i['value']
- writer.writerow([latitude, longitude,parkid,name,address,district,url,restaurace,wc,misto,mhd,sport,brusle,cesty,provoz,kolo,hriste,parking,doba])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement