Skip to main content

Load GTFS

Project description

py-gtfs-loader

Python 3.10+ License: MIT Build Status

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 functions
    • schema.py - GTFS entity definitions
    • schema_classes.py - Schema metadata system
    • types.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

Project details


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.3.1.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_gtfs_loader-0.3.1-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file py_gtfs_loader-0.3.1.tar.gz.

File metadata

  • Download URL: py_gtfs_loader-0.3.1.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for py_gtfs_loader-0.3.1.tar.gz
Algorithm Hash digest
SHA256 ac112bbe44e1bfaaacabf52f58ace4de0e74ff1ae1e7e37fee6302eafadfc7f7
MD5 2bee6d3459cc6618d8f4eced564cc9d5
BLAKE2b-256 cbff4784567b02839646aceefe5091c7a6ac2e2f9ece8b867169a47104d9f33f

See more details on using hashes here.

File details

Details for the file py_gtfs_loader-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for py_gtfs_loader-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7f4112e8abca64a3a5bc8b2e0ac1d5470026c5a3f59c530b6ecb0094e7c56e5
MD5 2bcb4d1d25a6e50f9fba05a90d01f0d5
BLAKE2b-256 9628ea432d2f42736e2635eb8b03daeb7276f7a1c66ebc1cbb6aed1a2561ef15

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page