Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Version 1.7.17

## Whats Changed

* Fix: :func:`petl.transform.fills.filldown` raised ``RuntimeError`` on a
header-only table (one with no data rows), whereas :func:`fillright` and
:func:`fillleft` return the header unchanged.
By :user:`sarathfrancis90`, :issue:`698`.

* ci: added readthedocs settings file
By :user:`juarezr`, :issue:`677`.

Expand Down
13 changes: 13 additions & 0 deletions petl/test/transform/test_fills.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ def test_filldown_headerless():
ieq(expect, actual)


def test_filldown_header_only():
table = (('foo', 'bar', 'baz'),)
expect = (('foo', 'bar', 'baz'),)

actual = filldown(table)
ieq(expect, actual)
ieq(expect, actual)

actual = filldown(table, 'bar')
ieq(expect, actual)
ieq(expect, actual)


def test_fillright():

table = (('foo', 'bar', 'baz'),
Expand Down
5 changes: 4 additions & 1 deletion petl/transform/fills.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ def iterfilldown(table, fillfields, missing):
if not fillfields: # fill down all fields
fillfields = hdr
fillindices = asindices(hdr, fillfields)
fill = list(next(it)) # fill values
try:
fill = list(next(it)) # fill values
except StopIteration:
return
yield tuple(fill)
for row in it:
outrow = list(row)
Expand Down
Loading