modified: app.py

This commit is contained in:
SimolZimol
2024-09-10 09:32:27 +02:00
parent 32ee77af8b
commit 9af76da31f

27
app.py
View File

@@ -38,18 +38,21 @@ def extract_relevant_data(weather_data):
station_info['Windgeschwindigkeit (m/s)'] = None
station_info['Windrichtung (Grad)'] = None
# Gehe durch die Einträge für jede Station
for entry in message:
if entry['key'] == 'stationOrSiteName':
station_info['Station_Name'] = entry['value']
elif entry['key'] == 'airTemperature':
station_info['Temperatur'] = entry['value'] - 273.15 # Umwandeln von Kelvin in Celsius
elif entry['key'] == 'pressureReducedToMeanSeaLevel':
station_info['Luftdruck (Pa)'] = entry['value']
elif entry['key'] == 'windSpeed':
station_info['Windgeschwindigkeit (m/s)'] = entry['value']
elif entry['key'] == 'windDirection':
station_info['Windrichtung (Grad)'] = entry['value']
# Iteriere durch die Liste, um die relevanten Schlüssel zu finden
for sub_message in message:
if isinstance(sub_message, list):
for entry in sub_message:
if isinstance(entry, dict) and 'key' in entry:
if entry['key'] == 'stationOrSiteName':
station_info['Station_Name'] = entry['value']
elif entry['key'] == 'airTemperature':
station_info['Temperatur'] = entry['value'] - 273.15 # Umwandeln von Kelvin in Celsius
elif entry['key'] == 'pressureReducedToMeanSeaLevel':
station_info['Luftdruck (Pa)'] = entry['value']
elif entry['key'] == 'windSpeed':
station_info['Windgeschwindigkeit (m/s)'] = entry['value']
elif entry['key'] == 'windDirection':
station_info['Windrichtung (Grad)'] = entry['value']
# Füge nur vollständig erfasste Stationen hinzu
if station_info['Station_Name'] and station_info['Temperatur'] is not None: