---
# System prepended metadata

title: Untitled

---

```
import json
import ssl
import urllib.request
import csv

# instant information of youbike
url = 'https://tcgbusfs.blob.core.windows.net/dotapp/youbike/v2/youbike_immediate.json'
context = ssl._create_unverified_context()

with urllib.request.urlopen(url, context=context) as jsondata:
    data = json.loads(jsondata.read().decode('utf-8-sig'))
    
# your csv file
file = open('/Users/Ken/Desktop/test.csv', mode='w')
writer = csv.writer(file)

writer.writerow(['sna', 'sbi', 'bemp', '空位比例'])
for i in data:
# only reserving stations aroud the main campus
    if (i['sna'].find('臺大') >= 0 or i['sna'].find('捷運公館站(3號出口)') >= 0) and i['sna'].find('醫') == -1 and i['sna'].find('臺大卓越研究大樓') == -1:
        print(i['sna'],'\t',i['sbi'],'\t',i['bemp'])
        writer.writerow([i['sna'], i['sbi'], i['bemp'], round(i['sbi'] / (i['sbi'] + i['bemp']), 2)])

file.close()
```