Skip to main content

A Python Library for GTFS

Project description

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

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

pygtfslib-0.1.2.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

pygtfslib-0.1.2-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file pygtfslib-0.1.2.tar.gz.

File metadata

  • Download URL: pygtfslib-0.1.2.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pygtfslib-0.1.2.tar.gz
Algorithm Hash digest
SHA256 94e988ade6f21406f0f261d5f122dcedb53542942a41b29886da16913d7a9f29
MD5 dbf5e87d9a517270f2d840f35c173f04
BLAKE2b-256 524343332232b76efe980bc5d706bd5e8723a27d673c8e7ec8f25941f2542a23

See more details on using hashes here.

Provenance

File details

Details for the file pygtfslib-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pygtfslib-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pygtfslib-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 11ba914656546a57d479158a7693870ebc959050f77ab0de3d37a23540959938
MD5 0f13ecde2db4f33f71d2813dfc19ea82
BLAKE2b-256 9da867cd412243c20450d59e01c270df0d0ca51428a9aac568db98e3f7981a6c

See more details on using hashes here.

Provenance

Supported by

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