Skip to content

Commit

Permalink
fix #1: values in cell with number-columns-repeated should have been …
Browse files Browse the repository at this point in the history
…appended
  • Loading branch information
chfw committed May 28, 2015
1 parent eafc22d commit 8dc28cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pyexcel_ods/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,23 +149,21 @@ def to_array(self):
for row in rows:
arrCells = []
cells = row.getElementsByType(TableCell)
has_value = False

# for each cell
for cell in cells:
# repeated value?
repeat = cell.getAttribute("numbercolumnsrepeated")
if(not repeat):
has_value = True
ret = self._read_cell(cell)
arrCells.append(ret)
else:
r = int(repeat)
ret = self._read_cell(cell)
for i in range(0, r):
arrCells.append("")
arrCells.append(ret)
# if row contained something
if(len(arrCells) and has_value):
arrRows.append(arrCells)
arrRows.append(arrCells)
return arrRows

def _read_text_cell(self, cell):
Expand Down
Binary file added tests/fixtures/repeated.ods
Binary file not shown.
9 changes: 9 additions & 0 deletions tests/test_bug_fixes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os
from pyexcel_ods import get_data


def test_bug_fix_for_issue_1():
data = get_data(os.path.join("tests", "fixtures", "repeated.ods"))
print data["Sheet1"]
assert data['Sheet1'] == [['repeated', 'repeated', 'repeated', 'repeated']]

0 comments on commit 8dc28cf

Please sign in to comment.