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 f1e50d1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pandas/io/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f1e50d1

Please sign in to comment.