@@ -234,7 +234,10 @@ def __init__(self, io, **kwds):
234
234
raise ImportError ("pandas requires xlrd >= 0.9.0 for excel "
235
235
"support, current version " + xlrd .__VERSION__ )
236
236
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 )
238
241
239
242
engine = kwds .pop ('engine' , None )
240
243
@@ -243,19 +246,19 @@ def __init__(self, io, **kwds):
243
246
244
247
# If io is a url, want to keep the data as bytes so can't pass
245
248
# 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 )
248
251
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 )
250
253
251
254
if engine == 'xlrd' and isinstance (self .io , xlrd .Book ):
252
255
self .book = self .io
253
256
elif not isinstance (self .io , xlrd .Book ) and hasattr (self .io , "read" ):
254
257
# N.B. xlrd.Book has a read attribute too
255
258
data = self .io .read ()
256
259
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 )
259
262
else :
260
263
raise ValueError ('Must explicitly set engine if not passing in'
261
264
' buffer or path for io.' )
0 commit comments