diff --git a/script/test-portland-gtfs-rm-routes b/script/test-portland-gtfs-rm-routes new file mode 100755 index 00000000000..97a0cfa9581 --- /dev/null +++ b/script/test-portland-gtfs-rm-routes @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +# This script can be used to delete routes from the Portland GTFS test data set. +# The script can remove a singe route or a range. Run the script from the OTP root. +# The script assume trip ida are constructed in a particular way; Hence can not +# be ysed on other gtfs data-set. +# +# To remove a single route with ID 4: +# +# > script/test-portland-gtfs-rm-routes 4 +# +# +# To remove all routes with ID 9(inclusive) to 73(exclusive): +# +# > script/test-portland-gtfs-rm-routes 9 73 +# + +pushd src/test/resources/portland/gtfs + +SERVICE_CODES="2fdkpABCKUPSWX" + +# This function takes one argument, the route ID +function removeRoute() { + TRIP_ID="${1}[01][${SERVICE_CODES}]" + echo "Remove route $1 and trips witch match: ${TRIP_ID}" + grep -v -E "^${1}," routes.txt > routes2.txt + mv routes2.txt routes.txt + + grep -v -E "^$1," trips.txt > trips2.txt + mv trips2.txt trips.txt + + grep -v -E "^${TRIP_ID}" stop_times.txt > stop_times2.txt + mv stop_times2.txt stop_times.txt + + grep -v -E "^\d+,\d+,${1}," transfers.txt > transfers2.txt + grep -v -E "^\d+,\d+,\d+,${1}," transfers2.txt > transfers3.txt + mv transfers3.txt transfers.txt + rm transfers2.txt + + grep -v -E "\d+,${1}," fare_rules.txt > fare_rules2.txt + mv fare_rules2.txt fare_rules.txt +} + + +if [ "$1" == "" ] +then + echo "Specify a route to remove or an range!" + popd + exit 1 +fi + +if [ "$2" == "" ] +then + removeRoute $1 +else + for ((i=$1; i <$2; ++i)) + do + removeRoute $i + done +fi + +popd