Skip to content

Commit aa3fefc

Browse files
mcrotTomAugspurger
authored andcommitted
BUG: Skip seek when loading Excel files from url (#20437)
Closes #20434. Back in #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 85c7900 commit aa3fefc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pandas/io/excel.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import abc
1111
import warnings
1212
import numpy as np
13+
from io import UnsupportedOperation
1314

1415
from pandas.core.dtypes.common import (
1516
is_integer, is_float,
@@ -388,8 +389,13 @@ def __init__(self, io, **kwds):
388389
elif not isinstance(io, xlrd.Book) and hasattr(io, "read"):
389390
# N.B. xlrd.Book has a read attribute too
390391
if hasattr(io, 'seek'):
391-
# GH 19779
392-
io.seek(0)
392+
try:
393+
# GH 19779
394+
io.seek(0)
395+
except UnsupportedOperation:
396+
# HTTPResponse does not support seek()
397+
# GH 20434
398+
pass
393399

394400
data = io.read()
395401
self.book = xlrd.open_workbook(file_contents=data)

0 commit comments

Comments
 (0)