-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpriors.py
More file actions
52 lines (39 loc) · 1.4 KB
/
priors.py
File metadata and controls
52 lines (39 loc) · 1.4 KB
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
46
47
48
49
50
51
52
# grabbing arrays of stops, line numbers, and, urls to call
import json
# grabs list of stops from the json input
def define_stops():
# grab json with stops
with open('ttc_lines_stations.json') as data_file:
stations = json.load(data_file)
stops = []
l = 0
while l < 4:
# number of stations on each line
station_count = len(stations['subwayLines'][l]['subwayStations'])
# for each station on that line
s = 0
while s < station_count:
station_id = stations['subwayLines'][l]['subwayStations'][s]['id']
line_id = stations['subwayLines'][l]['subwayStations'][s]['subwayLine']
name = stations['subwayLines'][l]['subwayStations'][s]['name']
pair = [station_id,line_id,name]
stops.append(pair)
s += 1
l += 1
return stops
# removes lines with no data
def stop_remover(stop_array,line_number):
new_stops = []
for row in stop_array:
if row[1] == line_number:
None
else:
new_stops.append(row)
return new_stops
# generates urls to call data from with stops and lines
def url_generator(stop_array):
urls = []
for row in stop_array:
url = "https://www.ttc.ca/Subway/loadNtas.action?subwayLine=" + str(row[1]) + "&stationId=" + str(row[0]) + "&searchCriteria=&_"
urls.append([row[0],row[1],url])
return urls