I am trying to look at the New York City Subway Realtime GTFS Feeds. After a lot of reading around, I learned about Protocol Buffers and installed the protoc
compiler.
New York City Transit has the file nyct-subway.proto.txt
the first line says NYCT Subway extensions for the GTFS-realtime protocol. Is this supposed by be combined with gtfs-realtime-proto
? I compiled the two protocol buffers separately and got the warning:
[libprotobuf WARNING google/protobuf/compiler/parser.cc:471]
No syntax specified for the proto file.
Please use 'syntax = "proto2";' or 'syntax = "proto3";' to specify a syntax version. (Defaulted to proto2 syntax.)
In Python wrote a line to call on whatever library protoc
had created:
import gtfs_realtime_pb2, nyct_subway_pb2
Despite my previous installation effort, Python didn't know anything about import google.protobuf
So it do sudo pip install protobuf
.
At this point I am still not reading any data -- I can get a gtfs file with http://datamine.mta.info/mta_esi.php?key=<key>&feed_id=1
which is unreadable.
How do I combine this to read the data from the GTFS file?
You can combine the two together by using the
protobuf
Python package. Download both.proto
file and place it intodocs/gtfs_proto
, create agtfs_proto
folder for the output and then run: