Python script to retrieve data from https://sharedmobility.ch, swisstopo and to inject it into a PostgreSQL table | Read-only mirror of https://github.com/sitn/mobility_updater — Canton de Neuchâtel. Issues & pull requests at the source.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2024-09-13 11:36:37 +02:00
logs Add logging and a timeout checker 2021-03-03 15:52:03 +01:00
mobility Code cleaning 2021-03-03 15:59:11 +01:00
scripts Be more specific for provider and stores 2024-09-10 14:32:22 +02:00
.gitignore Ignore pycache 2021-02-12 15:25:30 +01:00
config.yml.sample Be more specific for provider and stores 2024-09-10 14:32:22 +02:00
electric_mobility.py Code cleaning 2021-03-03 15:59:11 +01:00
LICENSE Initial commit 2021-02-05 15:37:37 +01:00
README.md Apply review 2024-05-15 14:04:18 +02:00
requirements.txt Update Python requirements 2024-05-14 09:05:18 +02:00
shared_mobility.py Adjust SQL values 2024-09-10 16:30:08 +02:00
timeout_checker.py Add logging and a timeout checker 2021-03-03 15:52:03 +01:00
truncater.py Add truncate script 2021-03-12 11:39:13 +01:00

Shared mobility updater

Requirements

Python 3.6+

Install

  • Get the code and create the virtual environment:
git clone https://github.com/sitn/mobility_updater.git
cd mobility_updater
python -m venv venv
venv\Scripts\pip install -r requirements.txt
  • Copy-paste the config.yml.sample file
  • Rename it to config.yml
  • Use the create_table.sql, adapt the table name and schema if necessary

That's it!

Run it

With cmd or powershell, cd to your shared_mobility_updater folder and:

  1. For the shared mobility part:
venv\Scripts\python shared_mobility.py
  1. For the electric stations part:
venv\Scripts\python electric_mobility.py

Purpose

The shared_mobility.py script gets data from the national shared mobility platform. The explanation can be found here

The electric_mobility.py script gets data from the national data infrastructure For electromobility:

  • Data access is described here

Disclaimer

This is a really "simple" script. There is no logging, no error handling, nothing like that. If you are willing to improve it, feel free, PRs are welcomed.