-
Notifications
You must be signed in to change notification settings - Fork 4
/
patch_raw_gtfs.sh
executable file
·49 lines (43 loc) · 1.78 KB
/
patch_raw_gtfs.sh
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
#!/bin/bash
set -e
set -o pipefail
name=$1
gtfs_dir=$2
if [ "$1" == "SPNV-BW" ]; then
1>&2 echo "SPNV-BW routes.txt: filling missing agency_id values"
set -x
mlr --csv put -S '$agency_id == "" { $agency_id = "00" }' "$gtfs_dir/routes.txt" | sponge "$gtfs_dir/routes.txt"
set +x
fi
if [ "$1" == "DELFI" ]; then
1>&2 echo "DELFI agency.txt: filling missing agency_url values"
set -x
mlr --csv put -S '$agency_url == "" { $agency_url = "https://www.delfi.de/" }' "$gtfs_dir/agency.txt" | sponge "$gtfs_dir/agency.txt"
# https://github.com/mfdz/GTFS-Issues/issues/71
grep -v '"",' "$gtfs_dir/stop_times.txt" | sponge "$gtfs_dir/stop_times.txt"
# https://github.com/mfdz/GTFS-Issues/issues/72
cat "$gtfs_dir/stop_times.txt" \
| grep -v '"de:08236:2590:2",' \
| grep -v '"de:08316:6667:2:1",' \
| grep -v '"de:08326:8324:90:",' \
| grep -v '"de:09676:99310:90",' \
| sponge "$gtfs_dir/stop_times.txt"
set +x
fi
if [ "$1" == "bwgesamt" ]; then
1>&2 echo "bwgesamt stops.txt: deleting rows with duplicate stop_ids"
set -x
# https://github.com/mfdz/GTFS-Issues/issues/74
grep -v '"de:09162:100_Parent","","München Hbf Gl. 27-36"' "$gtfs_dir/stops.txt" | sponge "$gtfs_dir/stops.txt"
# https://github.com/mfdz/GTFS-Issues/issues/75
tr -d '\r' < "$gtfs_dir/trips.txt" | sponge "$gtfs_dir/trips.txt"
tr -d '\r' < "$gtfs_dir/stop_times.txt" | sponge "$gtfs_dir/stop_times.txt"
# https://github.com/mfdz/GTFS-Issues/issues/77
sed -i 's/,www/,http:\/\/www/g' "$gtfs_dir/agency.txt"
sed -i 's/,"www/,"http:\/\/www/g' "$gtfs_dir/agency.txt"
# https://github.com/mfdz/GTFS-Issues/issues/76
sed -i 's/,,,"2/,"RB",,"2/' "$gtfs_dir/routes.txt"
# https://github.com/mfdz/GTFS-Issues/issues/78
uniq "$gtfs_dir/routes.txt" | sponge "$gtfs_dir/routes.txt"
set +x
fi