From 238c1e3f4056b263d8a1b21aac3eaa83b22fb3db Mon Sep 17 00:00:00 2001 From: Malcolm Morgan Date: Mon, 17 Jul 2023 19:38:14 +0100 Subject: [PATCH] Force read ids in stops.txt as character --- R/gtfs_merge.R | 4 ++-- R/gtfs_read.R | 10 +++++++++- R/nptdr_export.R | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/R/gtfs_merge.R b/R/gtfs_merge.R index 07aab29..a1f1b3e 100644 --- a/R/gtfs_merge.R +++ b/R/gtfs_merge.R @@ -20,7 +20,7 @@ gtfs_merge <- function(gtfs_list, force = FALSE, quiet = TRUE) { calendar <- sapply(gtfs_list, "[", "calendar") calendar_dates <- sapply(gtfs_list, "[", "calendar_dates") - # bind togther + # bind together names(agency) <- seq(1, length(agency)) suppressWarnings(agency <- dplyr::bind_rows(agency, .id = "file_id")) @@ -77,7 +77,7 @@ gtfs_merge <- function(gtfs_list, force = FALSE, quiet = TRUE) { agency <- unique(agency) if (any(duplicated(agency$agency_id))) { # Check for upppercase problems - # Sometime same agency with a captial letter in the name + # Sometime same agency with a capital letter in the name agency.check <- agency agency.check$agency_name <- tolower(agency.check$agency_name) agency.check <- unique(agency.check) diff --git a/R/gtfs_read.R b/R/gtfs_read.R index 8d37389..5f58818 100644 --- a/R/gtfs_read.R +++ b/R/gtfs_read.R @@ -28,7 +28,15 @@ gtfs_read <- function(path){ } if(checkmate::test_file_exists(file.path(tmp_folder,"stops.txt"))){ - gtfs$stops <- readr::read_csv(file.path(tmp_folder,"stops.txt"), lazy = FALSE, show_col_types = FALSE) + gtfs$stops <- readr::read_csv(file.path(tmp_folder,"stops.txt"), + col_types = readr::cols(stop_id = readr::col_character(), + stop_code = readr::col_character(), + stop_name = readr::col_character(), + stop_lat = readr::col_number(), + stop_lon = readr::col_number()), + + + lazy = FALSE, show_col_types = FALSE) } else { warning("Unable to find required file: stops.txt") } diff --git a/R/nptdr_export.R b/R/nptdr_export.R index 5e1245b..34479d0 100644 --- a/R/nptdr_export.R +++ b/R/nptdr_export.R @@ -119,7 +119,7 @@ nptdr_makeCalendar <- function(schedule, exceptions, historic_bank_holidays = hi calendar_dates <- nptdr_parse_bank_holidays(calendar_dates, bh) calendar_dates <- rbind(calendar_dates, cal_dates_exc, cal_dates_inc) - # TODO: Historical term times + # Historical term times data("school_terms") message("School term dates are illustrative and not exact")