Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

column name 'trip_headsign' not found error #15

Closed
polettif opened this issue May 10, 2019 · 1 comment
Closed

column name 'trip_headsign' not found error #15

polettif opened this issue May 10, 2019 · 1 comment

Comments

@polettif
Copy link
Collaborator

polettif commented May 10, 2019

Sorry for the possibly spammy issues but I had a look at this package again today and I've just run into these. If I try to run the router on this test feed I get the following error.

gtfs <- gtfsrouter::extract_gtfs("routing.zip")
gtfs <- gtfsrouter::gtfs_timetable(gtfs)
#> Day not specified; extracting timetable for Friday
gtfsrouter::gtfs_route(gtfs, from = "One", to = "Four", start_time = 7 * 3600)
#> Error in `[.data.table`(gtfs$trips, index, trip_headsign): j (the 2nd argument inside [...]) is a single symbol but column name 'trip_headsign' is not found. Perhaps you intended DT[, ..trip_headsign]. This difference to data.frame is deliberate and explained in FAQ 1.1.

Created on 2019-05-10 by the reprex package (v0.2.1)

It appears that gtfsrouter needs the optional trip_headsign column to work? Is there a way around that or should I simply add the column to the feed.

@mpadge
Copy link
Member

mpadge commented May 16, 2019

@polettif don't apologise - this is really helping to make the package more robust, so much appreciated! That commit now yields this response:

gtfs <- gtfsrouter::extract_gtfs("/data/mega/code/repos/atfutures/gtfs-router/routing.zip")
gtfs <- gtfsrouter::gtfs_timetable(gtfs)
#> Day not specified; extracting timetable for Thursday
gtfsrouter::gtfs_route(gtfs, from = "One", to = "Four", start_time = 7 * 3600)
#>   route_name stop_name arrival_time departure_time
#> 1     Line D       One     07:17:00       07:17:00
#> 2     Line D     Three     07:23:00       07:23:00
#> 3     Line B     Three     07:28:00       07:29:00
#> 4     Line B      Four     07:37:00       07:37:00

Created on 2019-05-16 by the reprex package (v0.2.1)

The trip_name column simply does not appear when trips has no trip_headsign column. The fix is a bit hacky, and what I need to do is more systematically go through the entire GTFS specs and ensure every "Optional" table and field are appropriately handled when not present, and so -> #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants