From 37c6a507f2e7c364896196782ae9b3d7ef5cea17 Mon Sep 17 00:00:00 2001 From: Bugazelle Date: Fri, 30 Aug 2019 00:21:40 +0800 Subject: [PATCH] [Fix] Fix bug if csv value is empty --- src/ExportCsvToInflux/csv_object.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/ExportCsvToInflux/csv_object.py b/src/ExportCsvToInflux/csv_object.py index c537dd8..a53dde9 100755 --- a/src/ExportCsvToInflux/csv_object.py +++ b/src/ExportCsvToInflux/csv_object.py @@ -156,12 +156,9 @@ def convert_csv_data_to_int_float(self, file_name): keys = row.keys() for key in keys: value = row[key] - # Continue if field no value - if len(str(value)) == 0: - continue # Valid Int Type try: - if float(row[key]).is_integer(): + if float(value).is_integer(): int_type[key].append(True) else: int_type[key].append(False) @@ -169,7 +166,7 @@ def convert_csv_data_to_int_float(self, file_name): int_type[key].append(False) # Valid Float Type try: - float(row[key]) + float(value) float_type[key].append(True) except ValueError: float_type[key].append(False) @@ -204,9 +201,6 @@ def convert_csv_data_to_int_float(self, file_name): keys = row.keys() for key in keys: value = row[key] - if len(str(value)) == 0: - row[key] = '' - continue int_status = int_type[key] if int_status is True: row[key] = int(float(value)) if int_type[key] is True else value