From f1e50d14b8ea3afe5831b46364158ecd20eb6f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20R=C3=B6ttger?= Date: Wed, 21 Mar 2018 11:39:37 +0100 Subject: [PATCH] BUG: Patch for skipping seek() when loading Excel files from url 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. --- pandas/io/excel.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pandas/io/excel.py b/pandas/io/excel.py index 0f9df845117db7..5bce37b9d77353 100644 --- a/pandas/io/excel.py +++ b/pandas/io/excel.py @@ -10,6 +10,7 @@ import abc import warnings import numpy as np +from io import UnsupportedOperation from pandas.core.dtypes.common import ( is_integer, is_float, @@ -388,8 +389,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 UnsupportedOperation: + # HTTPResponse does not support seek() + # GH 20434 + pass data = io.read() self.book = xlrd.open_workbook(file_contents=data)