Skip to main content

PyGTFSLib

A python library for the GTFS format.

So far, this is only a loose, incomplete collection of rather low-level tools for parsing GTFS feeds. The motivation for this library is to consolidate GTFS related code used at geOps in a single library. This is still work in progress, so breaking changes are to be expected.

This library aims to be efficient in terms of parsing time and memory usage to allow processing a large number of feeds.

Installation

Add the latest stable release from PyPI to your project with uv:

uv add pygtfslib

Modules

Spatial

The pygtfslib.spatial module contains classes and functions related to spatial data. So far, there is only one function read_shapes that can be used to parse shapes.txt using a generic factory that accepts an iterable of pygtfslib.spatial.ShapeRow instances.

Temporal

The pygtfslib.temporal module contains classes and functions related to temporal data. So far, it provides functions to parse calendar and frequency entries and stop times. It also provides a TimeCache class that accelerates conversion of GTFS timezone, operating day and time delta to a timezone-aware python datetime.datetime and back. Converting back shifts the operating day if needed since GTFS cannot express negative times or times of 100 hours or more. GTFS times can be parsed and formatted with the cached parse_timedelta and format_timedelta functions.

MOT

The pygtfslib.mot module contains tools related to GTFS route types / mode of transportation. So far, there is a function route_type_to_mot that can convert a GTFS route type or extended route type to a MOT string that can be used in the geOps routing engine.

CSV

The pygtfslib.fast_csv module contains low-level tools for CSV parsing. There are two generator functions that allow to iterate over a CSV file yielding rows as dicts or namedtuples. They are built on top of the builtin python CSV reader but they are faster than the builtin DictReader.

Issue Tracker

Please use the GitHub issue tracker to report bugs/issues.

Development

Contributing

If you want to contribute to the pygtfslib library, you can make a pull request at GitHub. Before working on major features/changes, please consider contacting us about your plans. See our GitHub page for contact details.

Editable Installation

Clone this repo and enter the corresponding directory. Then run:

uv sync

Pre-Commit Hooks

Enable pre-commit hooks:

uv run pre-commit install

From time to time (not automated yet) run

uv run pre-commit autoupdate

to update frozen revs.

Run tests

Run tests and analyze code coverage:

uv run pytest --cov=pygtfslib --cov-report term --cov-fail-under=40 pygtfslib

Build release for PyPI

Make sure to add a git tag first and push it to geOps gitlab and github.

Install build once:

uv tool install build

Then run

pyproject-build

Metadata

Release files for pygtfslib 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygtfslib 0.2.0
File Size Uploaded Provenance Actions
pygtfslib-0.2.0.tar.gz 48.8 kB Without provenance Details for pygtfslib-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pygtfslib 0.2.0
File Interpreter ABI Platform Actions
pygtfslib-0.2.0-py3-none-any.whl Python 3 none any Details for pygtfslib-0.2.0-py3-none-any.whl

Total release size: 63.7 kB

Release files / pygtfslib-0.2.0.tar.gz

Download URL pygtfslib-0.2.0.tar.gz
Size 48.8 kB
Tags Source
SHA-256 checksum
How to use checksums
93c3327a820209d5bc6c219d6cca40836b07ec85761823f3dcd6d7f9b83af7ad
BLAKE2b-256 checksum
How to use checksums
531820983a95b96d1d9fac4e8957daa3a0dcdac2dd92de0215ce6a16a26bc147
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pygtfslib-0.2.0-py3-none-any.whl

Download URL pygtfslib-0.2.0-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f7bda91d5f69303e6c0a6e2c86c3fae5a9b6e7c7cfe4bcd75955f8d2551feec8
BLAKE2b-256 checksum
How to use checksums
de14a787af04c627364e3ce66b8e45ad7c4f3f0ae4f8195e5f7b30d380d36481
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for pygtfslib 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page