Skip to content

Commit 7767703

Browse files
committed
BUG: Patch for skipping seek() when loading Excel files from url
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.
1 parent 5cf9773 commit 7767703

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pandas/io/excel.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,13 @@ def __init__(self, io, **kwds):
388388
elif not isinstance(io, xlrd.Book) and hasattr(io, "read"):
389389
# N.B. xlrd.Book has a read attribute too
390390
if hasattr(io, 'seek'):
391-
# GH 19779
392-
io.seek(0)
391+
try:
392+
# GH 19779
393+
io.seek(0)
394+
except (OSError, ValueError):
395+
# HTTPResponse does not support seek()
396+
# GH 20434
397+
pass
393398

394399
data = io.read()
395400
self.book = xlrd.open_workbook(file_contents=data)

0 commit comments

Comments
 (0)