Skip to content

Instantly share code, notes, and snippets.

View dimrizo's full-sized avatar

Dimitris Rizopoulos dimrizo

View GitHub Profile
@ian-weisser
ian-weisser / load_table
Last active July 28, 2016 13:32
Map GTFS table data into a python dict
def map_gtfs_table_to_dict(gtfs_file, table_name):
"""
Read data from a GTFS table, map the data into a list or dict for
easier iteration or searching or other use. Each line of the table
is mapped into a separate subdict, with a unique key.
Many GTFS tables include a unique value (Example: trips_id in the
trips.txt table) that this function automatically uses as the
dict key. If a tables has no unique key (Example: calendar_dates.txt),
the system generates a unique key using an incrementing row counter.