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

Install the latest stable release from PyPI with pip:

pip install 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.

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. Create a virtual environment, then install frozen requirements, dev-requirements and this library in editable mode:

python3.11 -m venv env
. env/bin/activate
pip install -U pip
pip install -r requirements.txt -r dev-requirements.txt -e .

Keep env activated for all following instructions.

Pre-Commit Hooks

Enable pre-commit hooks:

pre-commit install

From time to time (not automated yet) run

pre-commit autoupdate

to update frozen revs.

Run tests

Run tests and analyze code coverage:

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

Metadata

Release files for pygtfslib 0.1.3

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.1.3
File Size Uploaded
pygtfslib-0.1.3.tar.gz 15.9 kB Details

Built distribution (wheel)

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

Total release size: 28.8 kB

Release files / pygtfslib-0.1.3.tar.gz

Download URL pygtfslib-0.1.3.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cce7082e081bd677d3dc042d9c8fab75f98d320f9f0983ffa15b5f4357f4fd26
BLAKE2b-256 checksum
How to use checksums
4824ea3e75116e7444301f6511e4b90c54cbc069ac38d8c5deb98350268ef630
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.11

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

Download URL pygtfslib-0.1.3-py3-none-any.whl
Size 12.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f37922d62c7ba9f7ad5fbffa04bbd7f75faa230a7ebcf4b5161ac012d78b34a6
BLAKE2b-256 checksum
How to use checksums
41cb31ff072a41c7e009ef253b14015278fbc5e59a60e3ff3277639ab43e9146
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.11

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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