-
Notifications
You must be signed in to change notification settings - Fork 2
/
flo.yaml
67 lines (56 loc) · 2.12 KB
/
flo.yaml
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
########################################################### schedule information
# download the latest GTFS data. this should be done every month or so
---
creates: data/metra_gtfs.zip
command:
- mkdir -p $(dirname {{creates}})
- curl -L http://www.gtfs-data-exchange.com/agency/metra/latest.zip > {{creates}}
# unpack the latest GTFS data
---
creates: data/metra_gtfs/
depends: data/metra_gtfs.zip
command: unzip {{depends}} -d {{creates}}
# parse the GTFS data to configure a crontab that tracks every rail line
---
creates: data/crontab
depends:
- src/extract_crontab.py
- data/metra_gtfs/
command: python {{depends|join(' ')}} > {{creates}}
############################################### proof of concept from foia data
# download foia data from google docs
# https://aftership.uservoice.com/knowledgebase/articles/331269-csv-auto-fetch-using-google-drive-spreadsheet
---
creates: data/foia_arrival_departure.csv
command:
- mkdir -p $(dirname {{creates}})
- curl 'https://docs.google.com/spreadsheets/d/1bHTS-BiyC3vi8kTfVthejwh6Do0yJYmd4tKYybeBbVs/export?format=csv' > {{creates}}
# find all of the routes that are related to *my* usual trains
---
creates: data/morning_train.csv
depends: data/foia_arrival_departure.csv
command:
- head -n 1 {{depends}} > {{creates}}
- grep 'UP West,38,' {{depends}} >> {{creates}}
# find the scheduled time for train 38
---
creates: data/morning_schedule.csv
depends: data/metra_gtfs
stop_times: data/metra_gtfs/stop_times.txt
command:
- head -n 1 {{stop_times}} > {{creates}}
- grep 'UP-W_UW38_V1,' {{stop_times}} >> {{creates}}
# find the distance travelled along the route from the google download
---
creates: data/distance.dat
depends: data/metra_gtfs
shapes: data/metra_gtfs/shapes.txt
command:
- grep 'UP-W_IB_1' {{shapes}} | awk -F', ' 'BEGIN{a[3]=1;a[5]=1;a[7]=1;a[15]=1;a[18]=1;a[21]=1;a[24]=1;a[26]=1;a[27]=1;}{if(!($4 in a)) print $5}' > {{creates}}
---
creates: data/distance.js
depends: data/distance.dat
command:
- echo 'var distances = [\c' > {{creates}}
- awk 'BEGIN{sep=","}{if(NR==19) sep=""; printf("%f%s", $1, sep)}' {{depends}} >> {{creates}}
- echo '];' >> {{creates}}