Rubbedikatz / db_scripts

Scripts for interacting with Deutsche Bahn API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deutsche Bahn Delay Scanner

This project measures train delays at Germany's biggest train stations.

Getting started

Get your own data

  1. Clone this repo.
  2. Install dependencies, preferrably in a virtual environment.
pip install -r requirements.txt
  1. Run setup.py to create the database and get static information on train stations.
python setup.py
  1. Get a free Deutsche Bahn API key.
  2. Add your API Key to api_keys.txt at the line starting with dbapi = "".
  3. Run update_trips.py to collect data for trips at train stations of the first category in Germany at this moment.
python update_trips.py

Test with sample data instead
If you want to run an analysis without collecting your own data, you can download a database with sample data. The data was collected in 30 minute intervals with cronjobs running on a raspberry pi.

Explore
The notebook exploration.ipynb shows how the data is structured within the database.

Optional Weather Data
You can collect weather data to find out how delays are related to the local weather. Add an API key for OpenWeather.com to api_keys.txt and every time you execute update_trips.py also run

python update_weather.py

Author

Hannes Knobloch - Rubbedikatz

About

Scripts for interacting with Deutsche Bahn API


Languages

Language:Jupyter Notebook 83.4%Language:Python 11.4%Language:JavaScript 4.7%Language:HTML 0.5%