From ada00bf22a81f3e7e161a9822b690354ac76421b Mon Sep 17 00:00:00 2001 From: Nik Sauer Date: Mon, 10 Feb 2025 14:19:45 +0100 Subject: [PATCH] added None check for dimension and value --- code/download_csv.py | 2 ++ code/services/data_service.py | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/code/download_csv.py b/code/download_csv.py index cb6f194..6a9be60 100644 --- a/code/download_csv.py +++ b/code/download_csv.py @@ -121,6 +121,8 @@ def main(): # files that have already been downloaded cur_files = set(os.listdir(DOWNLOAD_FOLDER)) + + # filter for location rather then device_id db = next(get_db()) stations = set(str(s.device) for s in db.query(Station).all()) diff --git a/code/services/data_service.py b/code/services/data_service.py index cb660ce..bab5955 100644 --- a/code/services/data_service.py +++ b/code/services/data_service.py @@ -77,11 +77,13 @@ def sensor_community_import_grouped_by_location(db: Session, data: dict, source: # only add values if the measurement is not yet present for val in row['sensordatavalues']: - if not float_default(val['value']): + d = Dimension.get_dimension_from_sensor_community_name_import(val['value_type']) + v = float_default(val['value']) + if d is None or v is None: continue value = Values( - dimension = Dimension.get_dimension_from_sensor_community_name_import(val['value_type']), - value = float_default(val['value']), + dimension = d, + value = v, measurement_id = measurement.id ) db.add(value)