Skip to content

Commit

Permalink
[#125] Read past blank lines in an ODS file.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Read committed May 6, 2015
1 parent 6164f5c commit 90a83c7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
0.15 (wip, master)
* #125 Fix ODS stopping at blank lines
* #127 Fix reading of newer ODS files

0.14.1 (1 September 2014)
Expand Down
Binary file removed horror/annotated.ods
Binary file not shown.
Binary file added horror/blank_line.ods
Binary file not shown.
3 changes: 2 additions & 1 deletion messytables/ods.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def raw(self, sample=False):
row_data.append(c)

if not row_data:
raise StopIteration()
# ignore blank lines
continue

del partial
yield row_data
Expand Down
22 changes: 10 additions & 12 deletions test/test_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,18 +305,6 @@ def test_read_large_ods(self):
for row in row_set.sample:
assert len(row) == 5, len(row)

def test_annotated_ods(self):
fh = horror_fobj('annotated.ods')
table_set = ODSTableSet(fh)
assert_equal(4, len(table_set.tables))
row_set = table_set.tables[0]
for row in row_set.sample:
assert len(row) == 1, len(row)

row_set = table_set.tables[1]
l = len(list(row_set.sample))
assert 87 == l, l

def test_ods_version_4412(self):
fh = horror_fobj('loffice-4.4.1.2.ods')
table_set = ODSTableSet(fh)
Expand All @@ -328,6 +316,16 @@ def test_ods_version_4412(self):
assert_equal(rows[2][0], 'Jane')
assert_equal(rows[3][0], 'Ian')

def test_ods_read_past_blank_lines(self):
fh = horror_fobj('blank_line.ods')
table_set = ODSTableSet(fh)
assert_equal(1, len(table_set.tables))
row_set = table_set.tables[0]
rows = row_set_to_rows(row_set)
assert_equal(rows[0][0], 'Name')
assert_equal(rows[1][0], 'Bob')
assert_equal(rows[2][0], 'Jane')
assert_equal(rows[3][0], 'Ian')

def row_set_to_rows(row_set):
rows = []
Expand Down

0 comments on commit 90a83c7

Please sign in to comment.