Skip to content

Commit

Permalink
Merge pull request #9 from Bugazelle/dev
Browse files Browse the repository at this point in the history
[Feat] Release to 0.1.14
  • Loading branch information
Bugazelle authored Jul 19, 2019
2 parents a8f5cc6 + 9e802bb commit 20d9665
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ExportCsvToInflux/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.13'
__version__ = '0.1.14'
11 changes: 9 additions & 2 deletions src/ExportCsvToInflux/csv_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ def convert_csv_data_to_int_float(self, file_name):
for row in csv_reader:
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():
Expand Down Expand Up @@ -201,20 +205,23 @@ 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
else:
row[key] = float(value) if float_type[key] is True else value
yield row
yield row, int_type, float_type
if has_header is False and i == 1:
for key in keys:
int_status = int_type[key]
if int_status is True:
row[key] = int(float(key)) if int_type[key] is True else key
else:
row[key] = float(key) if float_type[key] is True else key
yield row
yield row, int_type, float_type
i += 1

def add_columns_to_csv(self,
Expand Down
18 changes: 17 additions & 1 deletion src/ExportCsvToInflux/exporter_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def export_csv_to_influx(self,
count = 0
timestamp = 0
convert_csv_data_to_int_float = csv_object.convert_csv_data_to_int_float(file_name=new_csv_file)
for row in convert_csv_data_to_int_float:
for row, int_type, float_type in convert_csv_data_to_int_float:
# Process Match & Filter: If match_columns exists and filter_columns not exists
match_status = self.__check_match_and_filter(row,
match_columns,
Expand Down Expand Up @@ -324,6 +324,14 @@ def export_csv_to_influx(self,
if limit_string_length_columns:
if tag_column in limit_string_length_columns:
v = str(v)[:limit_length + 1]
# If field is empty
if len(str(v)) == 0:
if int_type[tag_column] is True:
v = -999
elif float_type[tag_column] is True:
v = -999.0
else:
v = '-'
tags[tag_column] = v

# Process fields
Expand All @@ -335,6 +343,14 @@ def export_csv_to_influx(self,
if limit_string_length_columns:
if field_column in limit_string_length_columns:
v = str(v)[:limit_length + 1]
# If field is empty
if len(str(v)) == 0:
if int_type[field_column] is True:
v = -999
elif float_type[field_column] is True:
v = -999.9
else:
v = '-'
fields[field_column] = v

point = {'measurement': db_measurement, 'time': timestamp, 'fields': fields, 'tags': tags}
Expand Down

0 comments on commit 20d9665

Please sign in to comment.