Merge multiple GTFS files into one

gtfsmerger, gtfs, merge
pip install gtfsmerger==0.1.6


gtfs-merger build status

A Python package to merge multiple GTFS files into one


pip install gtfsmerger

Usage example

Use this module to merge two GTFS files

>>> from gtfsmerger import GTFSMerger
>>> gtfs_merger = GTFSMerger()
>>> gtfs_merger.merge_from_fpaths(['tests/', 'tests/'])

Can also use zipfile bytes as input, this is useful for Boto3

>>> merged_gtfs = GTFSMerger()
>>> f_1 = open('tests/', 'rb').read()
>>> f_2 = open('tests/', 'rb').read()
>>> merged_gtfs.merge_from_bytes_list([f_1, f_2])

To write the merged result to a ZIP file

>>> merged_gtfs.get_zipfile("./")

The class instance also contains a merged attribute, that is a dictionary of the merged GTFS Pandas DataFrames.

To list the GTFS Pandas DataFrames

>>> merged_gtfs.merged.keys()
dict_keys(['stops', 'stop_times', 'calendar_dates', 'shapes', 'agency', 'routes', 'trips'])

To access the stops GTFS Pandas Dataframe

>>> merged_gtfs.merged['stops'].head()
      stop_id    stop_name  stop_desc   stop_lat    stop_lon stop_url  \
0   0-n1502-1      美感ホール入口  掛川市内循環南回り  34.767448  138.010986      NaN
1  0-n62046-1  中東遠総合医療センター  掛川市内循環南回り  34.757321  137.998436      NaN
2   0-n1520-1       中央小学校前  掛川市内循環南回り  34.770991  138.005292      NaN
3   0-n1522-1      労金掛川支店前  掛川市内循環南回り  34.770798  138.008737      NaN
4     0-n1510      下俣南二丁目西  掛川市内循環南回り  34.762361  138.001036      NaN

  location_type parent_station wheelchair_boarding
0             0        0-n1502                   0
1             0       0-n62046                   0
2             0        0-n1520                   0
3             0        0-n1522                   0
4             1            NaN                   0


Note this package currently supports only Python3


virtualenv -p python3 venv
source venv/bin/activate

Install the dependency

make install

Run tests

make test