Skip to content
/ db-legs Public

From data of Deutsche Bahn API creates json output of legs between two cities

Notifications You must be signed in to change notification settings

J0ANMM/db-legs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

db-legs

Aim:

Create a clear and simple output of legs bewteen two cities from the data available in Deutsche Bahn API.

Instructions:

Since a GTFS with all extracted data from the DB API has already been created (great job!), those files will be used here as input. This allows to increase the speed drastically, as all information is downloaded once and there is no need to pull information from the DB

Code is split in 2 files / parts:

  • Part 1: Creates a table called 'legs' (SQLite) with all legs between two cities using the GFTS txt files
  • Part 2: From table 'legs' output JSON with all legs between two stations.

Output would look like this:

[
{
    "route_name": "ICE571",
    "departure_station": "8002549",
    "dep_st_name": "Hamburg Hbf",
    "arrival_station": "8000105",
    "arr_st_name": "Frankfurt(Main)Hbf",
    "departure_datetime": "2016-07-09 05:16",
    "arrival_datetime": "2016-07-09 09:00",
    "price": "?"
},
{
    "route_name": "ICE27",
    "departure_station": "8002549",
    "dep_st_name": "Hamburg Hbf",
    "arrival_station": "8000105",
    "arr_st_name": "Frankfurt(Main)Hbf",
    "departure_datetime": "2016-07-09 05:46",
    "arrival_datetime": "2016-07-09 12:13",
    "price": "?"
},
...

Steps

  1. Download latest GFTS release
  2. Run API_DB_part1.py
  3. Run API_DB_part2.py

Important

Code works, but it can definitely be optimized and improved. Any contribution to make it better is more than welcome! :)

Additional information:

Deutsche Bahn API:

In GitHub:

About

From data of Deutsche Bahn API creates json output of legs between two cities

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages