103
103
of dtype conversion.
104
104
engine : str, default None
105
105
If io is not a buffer or path, this must be set to identify io.
106
- Acceptable values are None, "auto", " xlrd", "openpyxl", "odf", or "pyxlsb".
106
+ Acceptable values are None, "xlrd", "openpyxl", "odf", or "pyxlsb".
107
107
File compatibility:
108
- "xlrd" engine supports .xls, .xlsx, and .xlsm files .
109
- "openpyxl" engine supports .xlsx, and .xlsm files .
110
- "odf" engine supports .odf, .ods, and .odt files .
111
- "pyxlsb" engine supports .xlsb files.
108
+ "xlrd" supports most old/new Excel file formats .
109
+ "openpyxl" engine supports newer Excel file formats .
110
+ "odf" engine supports OpenDocument file formats ( .odf, .ods, .odt) .
111
+ "pyxlsb" engine supports Binary Excel files.
112
112
converters : dict, default None
113
113
Dict of functions for converting values in certain columns. Keys can
114
114
either be integers or column labels, values are functions that take one
@@ -789,23 +789,23 @@ def close(self):
789
789
class ExcelFile :
790
790
"""
791
791
Class for parsing tabular excel sheets into DataFrame objects.
792
- Uses xlrd. See read_excel for more documentation
792
+ Uses xlrd by default . See read_excel for more documentation
793
793
794
794
Parameters
795
795
----------
796
796
io : str, path object (pathlib.Path or py._path.local.LocalPath),
797
797
a file-like object, xlrd workbook or openpypl workbook.
798
798
If a string or path object, expected to be a path to a
799
- .xls, .xlsx, .xlsb, .xlsm, .xltx , .xltm or .odf file.
799
+ .xls, .xlsx, .xlsb, .xlsm, .odf , .ods, or .odt file.
800
800
engine : str, default None
801
801
If io is not a buffer or path, this must be set to identify io.
802
- Acceptable values are None, ``auto``, `` xlrd``, ``openpyxl``,
802
+ Acceptable values are None, ``xlrd``, ``openpyxl``,
803
803
``odf``, or ``pyxlsb``.
804
804
File compatibility:
805
- ``xlrd`` engine supports .xls, .xlsx, and .xlsm files .
806
- ``openpyxl`` engine supports .xlsx, and .xlsm files .
807
- ``odf`` engine supports .odf, .ods, and .odt files .
808
- ``pyxlsb`` engine supports .xlsb files.
805
+ ``xlrd`` supports most old/new Excel file formats .
806
+ ``openpyxl`` engine supports newer Excel file formats .
807
+ ``odf`` engine supports OpenDocument file formats ( .odf, .ods, .odt) .
808
+ ``pyxlsb`` engine supports Binary Excel files.
809
809
"""
810
810
811
811
from pandas .io .excel ._odfreader import _ODFReader
@@ -820,15 +820,6 @@ class ExcelFile:
820
820
"pyxlsb" : _PyxlsbReader ,
821
821
}
822
822
823
- # Excel templates are not supported by read_excel according to the
824
- # documentation, but openpyxl specifies them as supported.
825
- _supported_engine_filetypes = {
826
- "xlrd" : ["xls" , "xlsx" , "xlsm" ],
827
- "openpyxl" : ["xlsx" , "xlsm" , "xltx" , "xltm" ],
828
- "odf" : ["odf" , "ods" , "odt" ],
829
- "pyxlsb" : ["xlsb" ],
830
- }
831
-
832
823
def __init__ (self , io , engine = None ):
833
824
if engine is None :
834
825
engine = "xlrd"
@@ -837,11 +828,7 @@ def __init__(self, io, engine=None):
837
828
838
829
self .engine = engine
839
830
840
- # 'io' could be a str, ExcelFile, Book, etc.
841
- if isinstance (io , str ):
842
- # Check engine-extension compatibility
843
- ext = os .path .splitext (io )[- 1 ][1 :]
844
- self .check_extension (engine , ext )
831
+ # Could be a str, ExcelFile, Book, etc.
845
832
self .io = io
846
833
# Always a string
847
834
self ._io = stringify_path (io )
@@ -921,32 +908,6 @@ def book(self):
921
908
def sheet_names (self ):
922
909
return self ._reader .sheet_names
923
910
924
- @classmethod
925
- def check_extension (cls , engine , ext ):
926
- """
927
- checks that the provided path's extension is supported by the reader engine.
928
- If it isn't supported, raises a ValueError.
929
- """
930
- if ext .startswith ("." ):
931
- ext = ext [1 :]
932
- if ext not in cls ._supported_engine_filetypes .get (engine ):
933
- supporting_engines = [
934
- k for k , v in cls ._supported_engine_filetypes .items () if ext in v
935
- ]
936
- if not supporting_engines :
937
- eng_info = " No engines currently support the provided file extension."
938
- else :
939
- eng_info = (
940
- " Use engine(s) "
941
- + ", " .join ("'{0}'" .format (e ) for e in supporting_engines )
942
- + " instead."
943
- )
944
- raise ValueError (
945
- f"Unsupported extension for engine '{ engine } ': '.{ ext } '." + eng_info
946
- )
947
- else :
948
- return True
949
-
950
911
def close (self ):
951
912
"""close io if necessary"""
952
913
self ._reader .close ()
0 commit comments