Skip to content

Instantly share code, notes, and snippets.

Last active November 8, 2020 14:59
What would you like to do?
Import GTFS data to MongoDB
mongoimport --db <dbname> --collection agencies --type csv --headerline --file agency.txt
mongoimport --db <dbname> --collection calendardates --type csv --headerline --file calendar_dates.txt
mongoimport --db <dbname> --collection calendars --type csv --headerline --file calendar.txt
mongoimport --db <dbname> --collection routes --type csv --headerline --file routes.txt
mongoimport --db <dbname> --collection stoptimes --type csv --headerline --file stop_times.txt
mongoimport --db <dbname> --collection stops --type csv --headerline --file stops.txt
mongoimport --db <dbname> --collection trips --type csv --headerline --file trips.txt
Copy link

  • to be entered in shell (assuming you have mongodb installed and your PATH setup correctly)
  • I only did this for a subset of the GTFS files because these are the only ones I needed - you can easily add the rest of the files the same way
  • I pluralized the collection names because that's how I needed them for my ORM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment