With transitfeed
, I've never seen in the docs any way to read an existing feed, which is one of the reasons I chose not to use it on my project.
There is a library called pygtfs
that extracts all the relevant informations from a gtfs feed, you can use its API to convert it into a format of you liking.
To read a gtfs feed (either a folder or a .zip
file), all you need to do is:
sched = pygtfs.Schedule(":memory:") # create a schedule object (a sqlite database)
pygtfs.append_feed(sched, "sample-gtfs-feed.zip") # add the GTFS feed to the database
There are then several methods in the API to make queries on the schedule object and obtain all the relevant infos about the feed (most of the time depending on the needs, you'll need only a portion of it).
Although if you need to work with massive feeds, or with feeds that do not completely comply with the standard (pygtfs is quite grumpy when it comes to that), I'd advice you to just unzip the feed and parse the file 'manually' to build a GTFS home-made object.
To encode data in json, the json
library does the job.