Skip to content

Commit ad2721b

Browse files
committed
BUG: Patch for skipping seek() when loading Excel files from url
Closes pandas-dev#20434.
1 parent 17c1fad commit ad2721b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pandas/io/excel.py

+5-1
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 http.client import HTTPResponse
1314

1415
from pandas.core.dtypes.common import (
1516
is_integer, is_float,
@@ -387,7 +388,10 @@ def __init__(self, io, **kwds):
387388
self.book = io
388389
elif not isinstance(io, xlrd.Book) and hasattr(io, "read"):
389390
# N.B. xlrd.Book has a read attribute too
390-
if hasattr(io, 'seek'):
391+
#
392+
# Excluding the case http.client.HTTPResponse.seek() here
393+
# because it raises an UnsupportedOperation exception
394+
if not isinstance(io, HTTPResponse) and hasattr(io, 'seek'):
391395
# GH 19779
392396
io.seek(0)
393397

0 commit comments

Comments
 (0)