Permalink
Browse files

issue #10 fix

  • Loading branch information...
dilshod committed Feb 14, 2012
1 parent 943e95c commit 528fe669c56b98ad02f5abb146eb91b724ce349c
Showing with 13 additions and 4 deletions.
  1. +3 −0 test/empty_row.csv
  2. BIN test/empty_row.xlsx
  3. +10 −4 xlsx2csv.py
View
@@ -0,0 +1,3 @@
+,,,,,,,,,,,,
+Date,Agency,Customer,Campaign,Publisher,Format,Inventory,Impressions,Clicks,CTR (%),Price,Price model,Revenue
+At the moment no data for report
View
Binary file not shown.
View
@@ -298,7 +298,11 @@ def handleStartElement(self, name, attrs):
self.colType = attrs.get("t")
self.s_attr = attrs.get("s")
cellId = attrs.get("r")
- self.colNum = cellId[:len(cellId)-len(self.rowNum)]
+ if cellId:
+ self.colNum = cellId[:len(cellId)-len(self.rowNum)]
+ self.colIndex = 0
+ else:
+ self.colIndex+= 1
#self.formula = None
self.data = ""
self.in_cell = True
@@ -324,7 +328,7 @@ def handleEndElement(self, name):
elif self.in_cell and name == 'c':
t = 0
for i in self.colNum: t = t*26 + ord(i) - 64
- self.columns[t - 1] = self.data
+ self.columns[t - 1 + self.colIndex] = self.data
self.in_cell = False
if self.in_row and name == 'row':
if len(self.columns.keys()) > 0:
@@ -405,5 +409,7 @@ def convert_recursive(path, kwargs):
else:
if len(args) > 1:
outfile = open(args[1], 'w+')
- else: outfile = sys.stdout
- xlsx2csv(args[0], outfile, **kwargs)
+ xlsx2csv(args[0], outfile, **kwargs)
+ outfile.close()
+ else:
+ xlsx2csv(args[0], sys.stdout, **kwargs)

0 comments on commit 528fe66

Please sign in to comment.