Skip to content

Commit

Permalink
Merge pull request #14 from Bugazelle/dev
Browse files Browse the repository at this point in the history
[Fix] Fix the separate issue
  • Loading branch information
Bugazelle authored Aug 10, 2019
2 parents f2ea320 + 153d87e commit 7fb26a7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ build/
*.egg-info
*.egg
*.pyc
debug*
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.16'
__version__ = '0.1.17'
2 changes: 1 addition & 1 deletion src/ExportCsvToInflux/csv_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def convert_csv_data_to_int_float(self, file_name):

# Yield Data
f.seek(0)
csv_reader = csv.DictReader(f)
csv_reader = csv.DictReader(f, delimiter=self.delimiter, lineterminator=self.lineterminator)
i = 1
for row in csv_reader:
keys = row.keys()
Expand Down
30 changes: 15 additions & 15 deletions src/ExportCsvToInflux/exporter_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ def __unix_time_millis(dt):

def export_csv_to_influx(self,
csv_file,
db_server_name,
db_user,
db_password,
db_name,
db_measurement,
tag_columns,
field_columns,
db_server_name='localhost:8086',
db_user='admin',
db_password='admin',
time_column='timestamp',
time_format='%Y-%m-%d %H:%M:%S',
delimiter=',',
Expand All @@ -138,7 +138,7 @@ def export_csv_to_influx(self,
"""Function: export_csv_to_influx
:param csv_file: the csv file path/folder
:param db_server_name: the influx server
:param db_server_name: the influx server (default localhost:8086)
:param db_user: the influx db user
:param db_password: the influx db password
:param db_name: the influx db name
Expand Down Expand Up @@ -384,24 +384,24 @@ def export_csv_to_influx(self,
print('Info: Wrote {0}, response: {1}'.format(data_points_len, response))

# Write count measurement
fields = dict()
fields['total'] = csv_file_length
for k, v in self.match_count.items():
k = 'match_{0}'.format(k)
fields[k] = v
for k, v in self.filter_count.items():
k = 'filter_{0}'.format(k)
fields[k] = v
count_point = [{'measurement': count_measurement, 'time': timestamp, 'fields': fields, 'tags': None}]
if enable_count_measurement:
fields = dict()
fields['total'] = csv_file_length
for k, v in self.match_count.items():
k = 'match_{0}'.format(k)
fields[k] = v
for k, v in self.filter_count.items():
k = 'filter_{0}'.format(k)
fields[k] = v
count_point = [{'measurement': count_measurement, 'time': timestamp, 'fields': fields, 'tags': None}]
response = client.write_points(count_point)
if response is False:
print('Error: Problem inserting points, exiting...')
exit(1)
print('Info: Wrote count measurement {0}, response: {1}'.format(count_point, response))

self.match_count = defaultdict(int)
self.filter_count = defaultdict(int)
self.match_count = defaultdict(int)
self.filter_count = defaultdict(int)

print('Info: Done')
print('')
Expand Down

0 comments on commit 7fb26a7

Please sign in to comment.