Skip to content

Commit

Permalink
Merge pull request #11 from Bugazelle/dev
Browse files Browse the repository at this point in the history
[Fix] Bug fix for issue-10
  • Loading branch information
Bugazelle authored Jul 20, 2019
2 parents 20d9665 + cde3afb commit bd9c0df
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 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.14'
__version__ = '0.1.15'
9 changes: 7 additions & 2 deletions src/ExportCsvToInflux/base_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ def str_to_list(self, string, delimiter=',', lower=False):
"""

string_type = type(string)
if string_type is list or string_type is tuple:
list_tuple_type = string_type is list or string_type is tuple
try:
str_unicode_type = string_type is str or string_type is unicode
except NameError:
str_unicode_type = string_type is str
if list_tuple_type:
if lower:
li = [str(item).strip(self.strip_chars).lower() for item in string]
else:
li = [str(item).strip(self.strip_chars) for item in string]
elif string_type is str or string_type is unicode:
elif str_unicode_type:
li = string.strip(self.strip_chars).split(delimiter)
if lower:
li = [item.strip(self.strip_chars).lower() for item in li]
Expand Down
8 changes: 4 additions & 4 deletions src/ExportCsvToInflux/csv_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,22 +268,22 @@ def add_columns_to_csv(self,
has_header = sniffer.has_header(f.read(40960))
f.seek(0)
source_reader = csv.DictReader(f, delimiter=self.delimiter, lineterminator=self.lineterminator)
new_headers = [x.keys()[0] for x in data]
new_headers = [list(x.keys())[0] for x in data]
with open(target, 'w+') as target_file:
target_writer = csv.writer(target_file, delimiter=self.delimiter, lineterminator=self.lineterminator)
row_id = 0
for row in source_reader:
values = row.values()
values = list(row.values())
if row_id == 0:
headers = row.keys()
headers = list(row.keys())
if has_header is False:
continue
headers += new_headers
target_writer.writerow(headers)
new_values = list()
for x in data:
try:
value = x.values()[0][row_id]
value = list(x.values())[0][row_id]
except IndexError:
print('Warning: The provided column length is less than with the source csv length. '
'Use "null" to fill the empty data')
Expand Down

0 comments on commit bd9c0df

Please sign in to comment.