gtfstools (version 0.1.0)

read_gtfs: Read and validate GTFS files

Description

Reads GTFS text files from either a local .zip file or an URL and validates them against GTFS specifications.

Usage

read_gtfs(path, files = NULL, quiet = TRUE, warnings = TRUE)

Arguments

path

The path to a GTFS .zip file.

files

A character vector containing the text files to be read from the GTFS (without the .txt extension). If NULL (the default) all existing files are read.

quiet

Whether to hide log messages and progress bars (defaults to TRUE).

warnings

Whether to display warning messages (defaults to TRUE).

Value

A GTFS object: a list of data.tables in which each index represents a GTFS text file. In case of parsing failures (e.g. files with more/less columns than specified in the file header), the function throws an error detailing where such failures occurred.

Details

The column types of each data.table in the final GTFS object conform as closely as possible to the Google's Static GTFS Reference. Exceptions are date-related columns (such as calendar.txt's start_date and end_date, for example), which are converted to Date objects, instead of being kept as integers, allowing for easier data manipulation. These columns are converted back to integers when writing the GTFS object to a .zip file using write_gtfs.

See Also

validate_gtfs

Examples

Run this code
# NOT RUN {
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")

gtfs <- read_gtfs(data_path)
names(gtfs)

gtfs <- read_gtfs(data_path, files = c("trips", "stop_times"))
names(gtfs)

# }

Run the code above in your browser using DataCamp Workspace