File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 44from io import BytesIO
55import os
66from textwrap import fill
7+ import warnings
78
89from pandas ._config import config
910
@@ -791,7 +792,7 @@ def close(self):
791792class ExcelFile :
792793 """
793794 Class for parsing tabular excel sheets into DataFrame objects.
794- Uses xlrd. See read_excel for more documentation
795+ Uses xlrd, openpyxl or odf . See read_excel for more documentation
795796
796797 Parameters
797798 ----------
@@ -811,8 +812,14 @@ class ExcelFile:
811812 _engines = {"xlrd" : _XlrdReader , "openpyxl" : _OpenpyxlReader , "odf" : _ODFReader }
812813
813814 def __init__ (self , io , engine = None ):
814- if engine is None :
815+ if engine == "xlrd" or engine is None :
815816 engine = "xlrd"
817+ warnings .warn (
818+ "xlrd is deprecated and will be removed in a future "
819+ "version. Use 'openpyxl' or 'odf' instead." ,
820+ FutureWarning ,
821+ stacklevel = 2 ,
822+ )
816823 if engine not in self ._engines :
817824 raise ValueError ("Unknown engine: {engine}" .format (engine = engine ))
818825
Original file line number Diff line number Diff line change @@ -39,3 +39,12 @@ def test_excel_table_sheet_by_index(datapath, read_ext):
3939 with pd .ExcelFile (path ) as excel :
4040 with pytest .raises (xlrd .XLRDError ):
4141 pd .read_excel (excel , "asdf" )
42+
43+
44+ def test_read_excel_with_default (datapath ):
45+ path = datapath ("io" , "data" , "test1.xls" )
46+ with tm .assert_produces_warning (
47+ FutureWarning , check_stacklevel = False , raise_on_extra_warnings = False
48+ ):
49+ with pd .ExcelFile (path ) as excel :
50+ pd .read_excel (excel , "Sheet1" )
You can’t perform that action at this time.
0 commit comments