afimb / gtfslib-python

An open source library in python for reading GTFS files and computing various stats and indicators about Public Transport networks
GNU General Public License v3.0
44 stars 6 forks source link

gtfslib-python

An open source library in python for reading GTFS files and computing various stats and indicators about Public Transport networks

Build Status

This software is open source (GPLv3); in particular, there is no warranty.

A more complete documentation can be found in the wiki

-> Pour des explications en français, voir la page FR du wiki

Installation

(Optional) You may want to setup a virtual environment before: (See https://virtualenv.readthedocs.org/ for more info.)

$ virtualenv <ENV>
$ . <ENV>/bin/activate

Download and install the lib:

$ git clone git@github.com:afimb/gtfslib-python.git
$ cd gtfslib-python
$ pip install .
$ gtfsdbloader --help

Usage

Command-line tool

$ gtfsdbloader --help

API tutorial

from gtfslib.dao import Dao
dao = Dao("db.sqlite")
dao.load_gtfs("mygtfs.zip")
for stop in dao.stops():
    print(stop.stop_name)
for route in dao.routes(fltr=Route.route_type == Route.TYPE_BUS):
    print("%s: %d trips" % (route.route_long_name, len(route.trips)))

For more information see here.

Data model

The internal model used, GTFS', is close to GTFS but simplified / normalized / expanded for ease of use.

The main differences are:

For the detail and more information see here.