File tree 2 files changed +24
-2
lines changed
2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 4
4
from io import BytesIO
5
5
import os
6
6
from textwrap import fill
7
+ import warnings
7
8
8
9
from pandas ._config import config
9
10
@@ -791,7 +792,7 @@ def close(self):
791
792
class ExcelFile :
792
793
"""
793
794
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
795
796
796
797
Parameters
797
798
----------
@@ -811,8 +812,13 @@ class ExcelFile:
811
812
_engines = {"xlrd" : _XlrdReader , "openpyxl" : _OpenpyxlReader , "odf" : _ODFReader }
812
813
813
814
def __init__ (self , io , engine = None ):
814
- if engine is None :
815
+ if engine == "xlrd" or engine is None :
815
816
engine = "xlrd"
817
+ warnings .warn (
818
+ "xlrd is deprecated. Alternative supported engines: 'openpyxl' or 'odf'." ,
819
+ FutureWarning ,
820
+ stacklevel = 2 ,
821
+ )
816
822
if engine not in self ._engines :
817
823
raise ValueError ("Unknown engine: {engine}" .format (engine = engine ))
818
824
Original file line number Diff line number Diff line change @@ -39,3 +39,19 @@ def test_excel_table_sheet_by_index(datapath, read_ext):
39
39
with pd .ExcelFile (path ) as excel :
40
40
with pytest .raises (xlrd .XLRDError ):
41
41
pd .read_excel (excel , "asdf" )
42
+
43
+
44
+ def test_excel_file_warning_with_default_engine (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
+ pd .ExcelFile (path )
50
+
51
+
52
+ def test_read_excel_warning_with_default_engine (tmpdir , datapath ):
53
+ path = datapath ("io" , "data" , "test1.xls" )
54
+ with tm .assert_produces_warning (
55
+ FutureWarning , check_stacklevel = False , raise_on_extra_warnings = False
56
+ ):
57
+ pd .read_excel (path , "Sheet1" )
You can’t perform that action at this time.
0 commit comments