Skip to content

Commit

Permalink
bug introduced by prior bug fix :-(, now fixed. (#108)
Browse files Browse the repository at this point in the history
csv schema should be developed.
  • Loading branch information
david-i-berry authored Jun 6, 2023
1 parent 35691c3 commit 8c94874
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions csv2bufr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#
###############################################################################

__version__ = '0.6.dev2'
__version__ = '0.6.2'

import csv
from datetime import timezone, datetime
Expand Down Expand Up @@ -588,11 +588,18 @@ def parse(self, data: dict, mappings: dict) -> None:
eccodes_key = element["eccodes_key"]
# get value
value = get_(eccodes_key, mappings[section], data)
# convert to expected data type
expected_type = self.dict[eccodes_key]["type"]
if (expected_type in ("float", "int")) and \
(eccodes_key not in HEADERS):
value = float(value)
if value in MISSING:
value = None
else:
# convert to expected data type
expected_type = self.dict[eccodes_key]["type"]
if (expected_type in ("float", "int")) and \
(eccodes_key not in HEADERS):
try:
value = float(value)
except Exception as e:
LOGGER.error("Error converting to expected type")
raise e
# ==============
# validate value
# ==============
Expand Down

0 comments on commit 8c94874

Please sign in to comment.