Skip to content

Commit

Permalink
Merge ffc1e81 into 1d33ca0
Browse files Browse the repository at this point in the history
  • Loading branch information
chrullrich committed Apr 23, 2019
2 parents 1d33ca0 + ffc1e81 commit 4a4f2f2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ci_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ numexpr==2.6.6
tables==3.4.4
intervaltree==2.1.0
lxml==4.2.3
openpyxl==2.5.4
openpyxl==2.6.2
pandas==0.22.0
#psycopg2==2.7.5
#PyMySQL==0.9.2
Expand Down
3 changes: 3 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Changes
Version X.X
-----------

* Updated :func:`petl.io.xlsx.fromxlsx` for compatibility with
openpyxl 2.6+ (:issue:`465` - :user:`chrullrich`).

* Added support for reading from remote sources with gzip or bz2 compression
(:issue:`463` - :user:`H-Max`).

Expand Down
6 changes: 4 additions & 2 deletions petl/io/xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ def __iter__(self):
if self.range_string is not None:
rows = ws[self.range_string]
else:
rows = ws.iter_rows(row_offset=self.row_offset,
column_offset=self.column_offset)
ws_max_row = ws.max_row or 0
ws_max_column = ws.max_column or 0
rows = ws.iter_rows(min_row=self.row_offset+1,
min_col=self.column_offset+1)

for row in rows:
yield tuple(cell.value for cell in row)
Expand Down
13 changes: 13 additions & 0 deletions petl/test/io/test_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ def test_fromxlsx():
ieq(expect, tbl)
ieq(expect, tbl)

def test_fromxlsx_offset():
filename = pkg_resources.resource_filename(
'petl', 'test/resources/test.xlsx'
)
tbl = fromxlsx(filename, 'Sheet1', row_offset=1, column_offset=1)
print(tbl.lookall())
expect = ((1,),
(2,),
(2,),
(datetime(2012, 1, 1, 0, 0),))
ieq(expect, tbl)
ieq(expect, tbl)

def test_fromxlsx_nosheet():
filename = pkg_resources.resource_filename(
'petl', 'test/resources/test.xlsx'
Expand Down

0 comments on commit 4a4f2f2

Please sign in to comment.