Skip to content

Instantly share code, notes, and snippets.

@deton
Last active September 2, 2024 12:16
Show Gist options
  • Save deton/964fe6ea43011e924f8a18c36d96b9d2 to your computer and use it in GitHub Desktop.
Save deton/964fe6ea43011e924f8a18c36d96b9d2 to your computer and use it in GitHub Desktop.
SDV (Synthetic Data Vault) trial using GBFS data

sdv-trial-gbfs

GaussianCopulaSynthesizer

CTGANSynthesizer

TVAESynthesizer

License

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
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=(',', ':')))
# 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}")
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.)

Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.)

Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment