Skip to content

Commit

Permalink
BUG: Patch for skipping seek() when loading Excel files from url
Browse files Browse the repository at this point in the history
Closes pandas-dev#20434.

Back in pandas-dev#19779 a call of a seek() method was added. This call fails
on HTTPResponse instances with an UnsupportedOperation exception,
so for this case a try..except wrapper was added here.
  • Loading branch information
mcrot committed Mar 22, 2018
1 parent 5cf9773 commit 7767703
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pandas/io/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,13 @@ def __init__(self, io, **kwds):
elif not isinstance(io, xlrd.Book) and hasattr(io, "read"):
# N.B. xlrd.Book has a read attribute too
if hasattr(io, 'seek'):
# GH 19779
io.seek(0)
try:
# GH 19779
io.seek(0)
except (OSError, ValueError):
# HTTPResponse does not support seek()
# GH 20434
pass

data = io.read()
self.book = xlrd.open_workbook(file_contents=data)
Expand Down

0 comments on commit 7767703

Please sign in to comment.