Skip to content

Commit

Permalink
strip empty lines from CSV data, fix #90
Browse files Browse the repository at this point in the history
  • Loading branch information
berteh committed Feb 5, 2019
1 parent 9d8bca1 commit ff16334
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ScribusGeneratorBackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,15 +553,17 @@ def substituteData(self, varNames, rows, lines, clean=CONST.CLEAN_UNUSED_EMPTY_V
return result

def getCsvData(self, csvfile):
# Read CSV file and return 2-dimensional list containing the data
# Read CSV file and return 2-dimensional list containing the data ,
# TODO check to replace with https://docs.python.org/3/library/csv.html#csv.DictReader
reader = csv.reader(file(csvfile), delimiter=self.__dataObject.getCsvSeparator(
), skipinitialspace=True, doublequote=True)
result = []
for row in reader:
rowlist = []
for col in row:
rowlist.append(col)
result.append(rowlist)
if(len(row) > 0): # strip empty lines in source CSV
rowlist = []
for col in row:
rowlist.append(col)
result.append(rowlist)
return result

def getLog(self):
Expand Down

0 comments on commit ff16334

Please sign in to comment.