-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_database.sh
More file actions
executable file
·43 lines (30 loc) · 2.35 KB
/
create_database.sh
File metadata and controls
executable file
·43 lines (30 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
curl "https://download-data.deutschebahn.com/static/datasets/stationsdaten/DBSuS-Uebersicht_Bahnhoefe-Stand2020-03.csv" -o sus-stationsdaten-2020-03.csv
curl "https://download-data.deutschebahn.com/static/datasets/stationsdaten_regio/DBRNI-Uebersicht_Bahnhoefe-Stand2020-04.csv" -o rni-stationsdaten-2020-04.csv
curl "https://download-data.deutschebahn.com/static/datasets/haltestellen/D_Bahnhof_2020_alle.CSV" -o sus-haltestellen-2020.csv
curl "https://download-data.deutschebahn.com/static/datasets/bahnsteig/DBSuS-Bahnsteigdaten-Stand2020-03.csv" -o sus-bahnsteigdaten-2020-03.csv
curl "https://download-data.deutschebahn.com/static/datasets/bahnsteig_regio/DBRNI-Bahnsteigdaten_erweitert-Stand2020-04.csv" -o rni-bahnsteigdaten-2020-04.csv
sqlite3 bahnhof.sqlite3 <<EOF
.mode csv
.separator ;
.import sus-stationsdaten-2020-03.csv sus_stationsdaten
.import rni-stationsdaten-2020-04.csv rni_stationsdaten
.import sus-haltestellen-2020.csv haltestellen
.import sus-bahnsteigdaten-2020-03.csv sus_bahnsteigdaten
.import rni-bahnsteigdaten-2020-04.csv rni_bahnsteigdaten
/*
bahnsteigdaten(bahnhofsnummer, bahnsteig, gleis, laenge, hoehe)
RegioNetz-Datensatz hat einfach keine Bahnsteigangaben, deswegen dichten wir jedem Gleis seinen eigenen dazu.
*/
CREATE VIEW bahnsteigdaten(quelle, bahnhofsnummer, bahnsteig, gleis, laenge, hoehe)
AS SELECT "sus", "Bahnhofsnummer", "Bahnsteig", "Gleisnummer", "Netto-baulänge (m)", "Höhe Bahnsteigkante (cm)""" FROM sus_bahnsteigdaten
UNION SELECT "rni", "Bf-Nr", rowid, "Bahnsteig-Nr.", "NETTOLAENGE [m]", "HOEHE [cm]" FROM rni_bahnsteigdaten;
/*
stationsdaten(regionalbereich,bahnhofsnummer,name,ds100,kategorie,strasse,plz,ort,bundesland,aufgabentraeger)
Die gemeinsamen Spalten von sus_stationsdaten und rni_stationsdaten.
*/
CREATE VIEW stationsdaten(quelle, regionalbereich, bahnhofsnummer, name, ds100, kategorie, strasse, plz, ort, bundesland, aufgabentraeger)
AS SELECT "sus", "RB", "Bf. Nr.", "Station", "Bf DS 100Abk.", "Kat. Vst", "Straße", "PLZ", "Ort", "Bundesland", "Aufgabenträger" FROM sus_stationsdaten
UNION SELECT "rni", "Regionalbereich", "Bf. Nr.", "Station", "Bf DS 100 Abk.", "Kategorie Vst", "Straße", "PLZ", "Ort", "Bundesland", "Aufgabenträger" FROM rni_stationsdaten;
CREATE VIEW bfnr_nichtinstationsdaten AS SELECT bahnhofsnummer from stationsdaten except select Betreiber_Nr from haltestellen;
EOF