Skips row having undefined asset_code
@@ -88,6 +88,7 @@ _MESSAGES_LIST = {
"e000030": "unable to create parent configuration category",
"e000031": "unable to convert in memory data structure related to the readings data "
"- error details |{0}| - row |{1}|",
+ "e000032": "asset code not defined - row |{0}|",
}
""" Messages used for Information, Warning and Error notice """
@@ -433,6 +434,9 @@ class SendingProcess(FoglampProcess):
try:
timestamp = apply_date_format(row['ts']) # Adds timezone UTC
asset_code = row['key'].strip()
+
+ # Skips row having undefined asset_code
+ if asset_code != "":
new_row = {
'id': row['id'],
'asset_code': asset_code,
@@ -441,6 +445,8 @@ class SendingProcess(FoglampProcess):
'user_ts': timestamp,
}
converted_data.append(new_row)
+ else:
+ SendingProcess._logger.warning(_MESSAGES_LIST["e000032"].format(row))
except Exception as e:
SendingProcess._logger.warning(_MESSAGES_LIST["e000022"].format(str(e), row))
@@ -471,6 +477,11 @@ class SendingProcess(FoglampProcess):
for row in raw_data:
try:
+
+ asset_code = row['asset_code'].replace(" ", "")
+
+ # Skips row having undefined asset_code
+ if asset_code != "":
# Converts values to the proper types, for example "180.2" to float 180.2
payload = row['reading']
@@ -480,12 +491,14 @@ class SendingProcess(FoglampProcess):
timestamp = apply_date_format(row['user_ts']) # Adds timezone UTC
new_row = {
'id': row['id'],
- 'asset_code': row['asset_code'],
+ 'asset_code': asset_code,
'read_key': row['read_key'],
'reading': payload,
'user_ts': timestamp
}
converted_data.append(new_row)
+ else:
+ SendingProcess._logger.warning(_MESSAGES_LIST["e000032"].format(row))
except Exception as e:
SendingProcess._logger.warning(_MESSAGES_LIST["e000031"].format(str(e), row))
