Skip to content

Instantly share code, notes, and snippets.

@dsamojlenko
Last active November 8, 2020 14:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dsamojlenko/4463143 to your computer and use it in GitHub Desktop.
Save dsamojlenko/4463143 to your computer and use it in GitHub Desktop.
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
@dsamojlenko
Copy link
Author

  • 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