Skip to content

Commit

Permalink
added None check for dimension and value
Browse files Browse the repository at this point in the history
  • Loading branch information
Nik Sauer committed Feb 10, 2025
1 parent 58ec49c commit ada00bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions code/download_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
8 changes: 5 additions & 3 deletions code/services/data_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ada00bf

Please sign in to comment.