Skip to content

Commit 1995f76

Browse files
committed
Avoid API change on ExcelWriter
1 parent 6e91a09 commit 1995f76

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pandas/io/excel.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,10 @@ def __init__(self, io, **kwds):
234234
raise ImportError("pandas requires xlrd >= 0.9.0 for excel "
235235
"support, current version " + xlrd.__VERSION__)
236236

237-
self.io = _stringify_path(io)
237+
# could be a str, ExcelFile, Book, etc.
238+
self.io = io
239+
# Always a string
240+
self._io = _stringify_path(io)
238241

239242
engine = kwds.pop('engine', None)
240243

@@ -243,19 +246,19 @@ def __init__(self, io, **kwds):
243246

244247
# If io is a url, want to keep the data as bytes so can't pass
245248
# to get_filepath_or_buffer()
246-
if _is_url(self.io):
247-
self.io = _urlopen(self.io)
249+
if _is_url(self._io):
250+
self._io = _urlopen(self._io)
248251
elif not isinstance(self.io, (ExcelFile, xlrd.Book)):
249-
self.io, _, _ = get_filepath_or_buffer(self.io)
252+
self._io, _, _ = get_filepath_or_buffer(self._io)
250253

251254
if engine == 'xlrd' and isinstance(self.io, xlrd.Book):
252255
self.book = self.io
253256
elif not isinstance(self.io, xlrd.Book) and hasattr(self.io, "read"):
254257
# N.B. xlrd.Book has a read attribute too
255258
data = self.io.read()
256259
self.book = xlrd.open_workbook(file_contents=data)
257-
elif isinstance(self.io, compat.string_types):
258-
self.book = xlrd.open_workbook(self.io)
260+
elif isinstance(self._io, compat.string_types):
261+
self.book = xlrd.open_workbook(self._io)
259262
else:
260263
raise ValueError('Must explicitly set engine if not passing in'
261264
' buffer or path for io.')

0 commit comments

Comments
 (0)