- *.py files are distributed under the terms of the MIT license.
- docomo-cycle.csv and hellocycling.csv:
- These sample data use the following copyrighted material with modifications.
- DOCOMO BIKESHARE, INC. / Association for Open Data of Public Transportation, Bikeshare information of DOCOMO BIKESHARE, INC., CC BY 4.0.
- OpenStreet Corp. / Association for Open Data of Public Transportation, Bikeshare information of OpenStreet, CC BY 4.0, ODC BY 1.0, ODbL 1.0.
- These sample data use the following copyrighted material with modifications.
Last active
September 2, 2024 12:16
-
-
Save deton/964fe6ea43011e924f8a18c36d96b9d2 to your computer and use it in GitHub Desktop.
SDV (Synthetic Data Vault) trial using GBFS data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python3 csv2hist.py sdv-gc-d.csv docomo-cycle >sdv-gc.ndjson | |
python3 csv2hist.py sdv-gc-h.csv hellocycling >>sdv-gc.ndjson | |
python3 csv2hist.py sdv-ctgan-d.csv docomo-cycle >sdv-ctgan.ndjson | |
python3 csv2hist.py sdv-ctgan-h.csv hellocycling >>sdv-ctgan.ndjson | |
python3 csv2hist.py sdv-tvae-d.csv docomo-cycle >sdv-tvae.ndjson | |
python3 csv2hist.py sdv-tvae-h.csv hellocycling >>sdv-tvae.ndjson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import sys | |
fname = sys.argv[1] | |
systemId = sys.argv[2] | |
statuslist = [] | |
stinfo = {} | |
with open(fname) as f: | |
for line in f: | |
line = line.rstrip('\r\n') | |
stationId, lat, lon, capacity = line.split(',') | |
if stationId == 'station_id': # header line | |
continue | |
stinfo[stationId] = [float(lat), float(lon)] | |
statuslist.append([stationId, int(capacity)]) | |
outdic = { | |
'ts': '2024-08-15T00:02', | |
'system_id': systemId, | |
'status': statuslist, | |
'stations': stinfo, | |
} | |
print(json.dumps(outdic, ensure_ascii=False, separators=(',', ':'))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: python3 gbfs2capacitycsv.py 15/0002hellocycling_station_information.json | |
import json | |
import sys | |
print('station_id,lat,lon,capacity') | |
for stfname in sys.argv[1:]: | |
with open(stfname) as f: | |
info = json.load(f) | |
for s in info['data']['stations']: | |
capacity = s.get('capacity', s.get('vehicle_capacity')) | |
print(f"{s['station_id']},{s['lat']},{s['lon']},{capacity}") |
View raw
(Sorry about that, but we can’t show files that are this big right now.)
View raw
(Sorry about that, but we can’t show files that are this big right now.)
View raw
(Sorry about that, but we can’t show files that are this big right now.)
View raw
(Sorry about that, but we can’t show files that are this big right now.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment