Skip to content

Commit 494b0a3

Browse files
committed
fix #2: read all texts inside the same child
1 parent 94cc3d6 commit 494b0a3

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

pyexcel_odsr/messyods.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,19 +190,22 @@ def _read_cell(element):
190190

191191

192192
def _read_text_cell(element):
193-
children = element.getchildren()
194-
text_content = []
195-
for child in children:
196-
if child.text:
197-
text_content.append(child.text)
198-
else:
199-
text_content.append('')
193+
text_content = _recursively_read_text_cell(element)
200194
if len(text_content) > 0:
201195
cell_value = '\n'.join(text_content)
202196
else:
203197
cell_value = ''
204198
return (cell_value, 'string')
205199

206200

201+
def _recursively_read_text_cell(element):
202+
children = element.getchildren()
203+
texts = []
204+
for child in children:
205+
text = "".join([x for x in child.itertext()])
206+
texts.append(text)
207+
return texts
208+
209+
207210
def _tag(namespace, tag):
208211
return '{%s}%s' % (namespace, tag)

tests/test_bug_fixes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,10 @@ def test_issue_1_error():
7474
from pyexcel_odsr.converter import time_value
7575
result = time_value('PT1111')
7676
eq_(result, None)
77+
78+
79+
def test_issue_19():
80+
test_file = "pyexcel_81_ods_19.ods"
81+
data = get_data(os.path.join("tests", "fixtures", test_file),
82+
skip_empty_rows=True, library='pyexcel-odsr')
83+
eq_(data['product.template'][1][1], 'PRODUCT NAME PMP')

0 commit comments

Comments
 (0)