remix / partridge

A fast, forgiving GTFS reader built on pandas DataFrames
https://partridge.readthedocs.io
MIT License
151 stars 22 forks source link

write_feed_dangerously usage #41

Closed cjer closed 6 years ago

cjer commented 6 years ago

I would like to have the option for creating a valid pruned GTFS feed based on a partridge feed. I tried to use write_feed_dangerously, but:

  1. I can't seem to figure out how to get back to a partridge feed from this. Can this be easily done somehow?
  2. I have noticed it really isn't a valid GTFS feed. Is there any plan or work in progress for doing so?

Thanks

invisiblefunnel commented 6 years ago

Hi @cjer. I recommend using ptg.writers.extract_feed, instead of using write_feed_dangerously.

inpath = 'mygtfs.zip'
outpath = 'mygtfs-pruned.zip'
agency_ids = ['2', '4']

ptg.writers.extract_feed(inpath, outpath, {
    {'routes.txt': {'agency_id': agency_ids}}
})

feed = ptg.feed(outpath)

Does that work for your use case?

cjer commented 6 years ago

Hey! that seems to work great!

docs anyone? :)

invisiblefunnel commented 6 years ago

I recently added extract_feed to the docs under "Extracting a new feed" in the Usage section: https://github.com/remix/partridge#usage.