š go-gtfs - Awesome Go Library for File Handling
Load gtfs files in go.
š·ļø File Handling
š Libraries for handling files and file systems.
ā 44 stars
Detailed Description of go-gtfs
go-gtfs
Load GTFS files in Go.
The project is in maintenance mode.
It is kept compatible with changes in the Go ecosystem but no new features will be developed. PR could be accepted.
Install
go get github.com/artonge/go-gtfs
Examples
Load one directory containing GTFS files:
path/to/gtfs_files
āāā agency.txt
āāā attributions.txt
āāā calendar_dates.txt
āāā calendar.txt
āāā fare_attributes.txt
āāā fare_rules.txt
āāā feed_info.txt
āāā frequencies.txt
āāā levels.txt
āāā pathways.txt
āāā routes.txt
āāā shapes.txt
āāā stops.txt
āāā stop_times.txt
āāā transfers.txt
āāā trips.txt
g, err := gtfs.Load("path/to/gtfs_files", nil)
Load a directory containing sub directories containing GTFS files:
path/to/gtfs_directories
āāā gtfs1
ā āāā agency.txt
ā āāā attributions.txt
ā āāā calendar_dates.txt
ā āāā calendar.txt
ā āāā fare_attributes.txt
ā āāā fare_rules.txt
ā āāā feed_info.txt
ā āāā frequencies.txt
ā āāā levels.txt
ā āāā pathways.txt
ā āāā routes.txt
ā āāā shapes.txt
ā āāā stops.txt
ā āāā stop_times.txt
ā āāā transfers.txt
ā āāā trips.txt
āāā gtfs2
āāā agency.txt
āāā attributions.txt
āāā calendar_dates.txt
āāā calendar.txt
āāā fare_attributes.txt
āāā fare_rules.txt
āāā feed_info.txt
āāā frequencies.txt
āāā levels.txt
āāā pathways.txt
āāā routes.txt
āāā shapes.txt
āāā stops.txt
āāā stop_times.txt
āāā transfers.txt
āāā trips.txt
gs, err := gtfs.LoadSplitted("path/to/gtfs_directories", nil)
You can then access the data through the GTFS structure. That structure contains arrays of approriate structures for each files.
type GTFS struct {
Path string // The path to the containing directory
Agency Agency
Agencies []Agency
Attributions []Attribution
Calendars []Calendar
CalendarDates []CalendarDate
FareAttributes []FareAttribute
FareRules []FareRule
FeedInfos []FeedInfo
Frequencies []Frequency
Levels []Level
Routes []Route
Pathways []Pathway
Shapes []Shape
Stops []Stop
StopsTimes []StopTime
Trips []Trip
Transfers []Transfer
}
type Route struct {
ID string `csv:"route_id"`
AgencyID string `csv:"agency_id"`
ShortName string `csv:"route_short_name"`
LongName string `csv:"route_long_name"`
Type int `csv:"route_type"`
Desc string `csv:"route_desc"`
URL string `csv:"route_url"`
Color string `csv:"route_color"`
TextColor string `csv:"route_text_color"`
}
...
Contributions
Pull requests are welcome ! :)