py-gtfs-loader
A Python library for loading and manipulating GTFS (General Transit Feed Specification) data with schema validation and type safety.
Features
- 📦 Load GTFS feeds from directories
- ✅ Schema validation with type checking
- 🔄 Modify and patch GTFS data
- 🚀 Support for standard GTFS and Transit's itinerary format
- 📝 CSV and GeoJSON file type support
- 🔗 Cross-referenced entities for easy data navigation
Installation
pip install py-gtfs-loader
Or using uv:
uv add py-gtfs-loader
Quick Start
Loading GTFS Data
import gtfs_loader
# Load a GTFS feed
gtfs = gtfs_loader.load('path/to/gtfs/directory')
# Access data by entity
stop = gtfs.stops['stop_id']
route = gtfs.routes['route_id']
trip = gtfs.trips['trip_id']
# Access grouped entities
stop_times = gtfs.stop_times['trip_id'] # Returns list of stop times for a trip
Modifying and Saving GTFS Data
# Modify data
gtfs.stops['stop_id'].stop_name = "New Stop Name"
# Save changes back to disk
gtfs_loader.patch(gtfs, 'path/to/input', 'path/to/output')
Loading Specific Files
# Load only specific files
gtfs = gtfs_loader.load('path/to/gtfs', files=['stops', 'routes', 'trips'])
Transit Itinerary Format
# Load Transit itinerary format (itinerary_cells.txt)
gtfs = gtfs_loader.load('path/to/gtfs', itineraries=True)
Development
This project uses uv for dependency management.
Setup
# Install dependencies
uv sync --all-extras --dev
# Run tests
uv run pytest .
# Run linting
uv run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
Requirements
- Python ≥ 3.10
- Development dependencies: pytest, flake8
Project Structure
gtfs_loader/- Main package__init__.py- Load/patch functionsschema.py- GTFS entity definitionsschema_classes.py- Schema metadata systemtypes.py- Custom GTFS types (GTFSTime, GTFSDate, Entity)lat_lon.py- Geographic utilities
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details
Maintainers
- Jonathan Milot
- Jeremy Steele
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py_gtfs_loader-0.4.0.tar.gz
(14.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_gtfs_loader-0.4.0.tar.gz.
File metadata
- Download URL: py_gtfs_loader-0.4.0.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0155dd23e2c2c9fbf69029263adc94018f29ce52a994ad55aa6a7a2394132353
|
|
| MD5 |
ef9556214031c10adaad4385affabf0d
|
|
| BLAKE2b-256 |
08211aae46816e5bff7f32812345d5f96a623d345aeb7d283a9ea7ddc25177b1
|
File details
Details for the file py_gtfs_loader-0.4.0-py3-none-any.whl.
File metadata
- Download URL: py_gtfs_loader-0.4.0-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c994de577bbe1004c9ae8f4dd3cb504b5b13f84f1b86194f6ff53df520f66d5
|
|
| MD5 |
294ec4aa342d62bfd33554c5970f8d45
|
|
| BLAKE2b-256 |
3e267ec34f42029f0763d14a82fc2e4bf0d7857c941f10fd73d75cf1b8afdc35
|