Eigene Datenquelle hinzufügen¶
Die aktuellen Quellen sind Start-Templates. Um eine weitere offizielle/offene Quelle hinzuzufügen, kopiert man den passendsten Block in configs/sources.yml, ändert ID und Zugriffsdaten und startet danach das Ingest-Skript.
Ablauf¶
- Offizielle Quelle, API, STAC-Collection, SPARQL-Endpunkt oder BFS-PX-Web-Tabelle finden.
- Passenden Connector-Typ aus der Tabelle wählen.
- Neuen Block unter
sources:inconfigs/sources.ymlergänzen. - Mit
python scripts/ingest.py --listprüfen, ob die Quelle registriert ist. - Mit
python scripts/ingest.py --source your_source_idabrufen. data/raw/your_source_id/<timestamp>/payload.*undmetadata.jsonprüfen.
Connector-Typen¶
| Anwendungsfall | Connector-Typ | Vorlage |
|---|---|---|
| Direkte CSV-, HTML-, PDF- oder Datei-URL | http_file |
sfoe_energy_balance_csv oder armasuisse_st_publications |
| Einfache JSON-API mit Parametern | http_json |
parliament_affairs |
| JSON-API mit POST-Body | http_post_json |
aramis_armasuisse_research_projects |
| opendata.swiss CKAN-Paket | ckan_package_show |
opendata_swiss |
| opendata.swiss CKAN-Suche | ckan_package_search |
Gleiche base_url, plus params |
| geo.admin.ch oder MeteoSchweiz STAC | stac_collection |
meteo_swiss_smn oder geoadmin_* |
| SPARQL als JSON | sparql |
fedlex |
| SPARQL als CSV | sparql_csv |
lindas |
| BFS / STAT-TAB PX-Web | pxweb_query |
bfs_pxweb |
Minimalbeispiele¶
Direkte CSV oder Datei¶
my_csv_source:
source_name: My official CSV source
enabled: true
type: http_file
format: CSV
url: https://example.admin.ch/data.csv
suffix: csv
documentation:
url: https://example.admin.ch
access_path: Direct CSV download
license_or_terms: Check official terms
geographic_reference: Switzerland / dataset dependent
update_logic: Dataset dependent
JSON-API¶
my_json_api:
source_name: My JSON API source
enabled: true
type: http_json
format: JSON
url: https://example.admin.ch/api/items
params:
limit: 100
language: en
documentation:
url: https://example.admin.ch/api
access_path: /api/items?limit=100&language=en
license_or_terms: Check official terms
geographic_reference: Switzerland / dataset dependent
update_logic: API dependent
STAC-Collection¶
my_geodata_layer:
source_name: My geo.admin.ch layer
enabled: true
type: stac_collection
format: STAC / JSON metadata / geodata assets
collection_url: https://data.geo.admin.ch/api/stac/v1/collections/ch.example.layer
documentation:
url: https://data.geo.admin.ch
access_path: /api/stac/v1/collections/ch.example.layer
license_or_terms: Per geo.admin.ch / dataset metadata
geographic_reference: Switzerland / geospatial layer
update_logic: Dataset dependent
SPARQL-Abfrage¶
my_sparql_source:
source_name: My SPARQL source
enabled: true
type: sparql_csv
format: SPARQL CSV results
endpoint: https://ld.admin.ch/query
query: |
SELECT ?s ?p ?o
WHERE {
?s ?p ?o .
}
LIMIT 100
documentation:
url: https://ld.admin.ch
access_path: /query?format=csv&query=<your query>
license_or_terms: Dataset dependent
geographic_reference: Switzerland / dataset dependent
update_logic: Dataset dependent
Ausführen¶
python scripts/ingest.py --list
python scripts/ingest.py --source my_csv_source
Lokal unter Windows im virtuellen Environment:
.\.venv\Scripts\python.exe scripts\ingest.py --source my_csv_source
Was dokumentiert werden muss¶
| Feld | Zweck |
|---|---|
url |
Offizielle Dokumentation oder Landingpage. |
access_path |
Exakter API-Pfad, Datei-URL, Query oder Tabellenpfad. |
license_or_terms |
Nutzungsbedingungen für die Hackathon-Abgabe. |
geographic_reference |
Schweiz, Kanton, Gemeinde, Station, Polygon usw. |
update_logic |
Wie oft oder durch welchen Prozess die Quelle aktualisiert wird. |
So entsteht nicht nur ein Download, sondern eine nachvollziehbare Datenlinie.