|
25 | 25 | from pandas.io.common import IOHandles, get_handle, stringify_path, validate_header_arg
|
26 | 26 | from pandas.io.excel._util import (
|
27 | 27 | fill_mi_header,
|
28 |
| - get_default_writer, |
| 28 | + get_default_engine, |
29 | 29 | get_writer,
|
30 | 30 | maybe_convert_usecols,
|
31 | 31 | pop_header_name,
|
|
123 | 123 | then `odf <https://pypi.org/project/odfpy/>`_ will be used.
|
124 | 124 | - Otherwise if ``path_or_buffer`` is an xls format,
|
125 | 125 | ``xlrd`` will be used.
|
| 126 | + - Otherwise if ``path_or_buffer`` is in xlsb format, |
| 127 | + ``pyxlsb`` will be used. |
| 128 | +
|
| 129 | + .. versionadded:: 1.3.0 |
126 | 130 | - Otherwise if `openpyxl <https://pypi.org/project/openpyxl/>`_ is installed,
|
127 | 131 | then ``openpyxl`` will be used.
|
128 | 132 | - Otherwise if ``xlrd >= 2.0`` is installed, a ``ValueError`` will be raised.
|
@@ -707,7 +711,7 @@ def __new__(cls, path, engine=None, **kwargs):
|
707 | 711 | try:
|
708 | 712 | engine = config.get_option(f"io.excel.{ext}.writer", silent=True)
|
709 | 713 | if engine == "auto":
|
710 |
| - engine = get_default_writer(ext) |
| 714 | + engine = get_default_engine(ext, mode="writer") |
711 | 715 | except KeyError as err:
|
712 | 716 | raise ValueError(f"No engine for filetype: '{ext}'") from err
|
713 | 717 |
|
@@ -1009,6 +1013,10 @@ class ExcelFile:
|
1009 | 1013 | then `odf <https://pypi.org/project/odfpy/>`_ will be used.
|
1010 | 1014 | - Otherwise if ``path_or_buffer`` is an xls format,
|
1011 | 1015 | ``xlrd`` will be used.
|
| 1016 | + - Otherwise if ``path_or_buffer`` is in xlsb format, |
| 1017 | + `pyxlsb <https://pypi.org/project/pyxlsb/>`_ will be used. |
| 1018 | +
|
| 1019 | + .. versionadded:: 1.3.0 |
1012 | 1020 | - Otherwise if `openpyxl <https://pypi.org/project/openpyxl/>`_ is installed,
|
1013 | 1021 | then ``openpyxl`` will be used.
|
1014 | 1022 | - Otherwise if ``xlrd >= 2.0`` is installed, a ``ValueError`` will be raised.
|
@@ -1065,21 +1073,10 @@ def __init__(
|
1065 | 1073 | )
|
1066 | 1074 |
|
1067 | 1075 | if engine is None:
|
1068 |
| - if ext == "ods": |
1069 |
| - engine = "odf" |
1070 |
| - elif ext == "xls": |
1071 |
| - engine = "xlrd" |
1072 |
| - else: |
1073 |
| - # GH 35029 - Prefer openpyxl except for xls files |
1074 |
| - if ( |
1075 |
| - import_optional_dependency( |
1076 |
| - "openpyxl", raise_on_missing=False, on_version="ignore" |
1077 |
| - ) |
1078 |
| - is not None |
1079 |
| - ): |
1080 |
| - engine = "openpyxl" |
1081 |
| - else: |
1082 |
| - engine = "xlrd" |
| 1076 | + # ext will always be valid, otherwise inspect_excel_format would raise |
| 1077 | + engine = config.get_option(f"io.excel.{ext}.reader", silent=True) |
| 1078 | + if engine == "auto": |
| 1079 | + engine = get_default_engine(ext, mode="reader") |
1083 | 1080 |
|
1084 | 1081 | if engine == "xlrd" and ext != "xls" and xlrd_version is not None:
|
1085 | 1082 | if xlrd_version >= "2":
|
@@ -1107,7 +1104,6 @@ def __init__(
|
1107 | 1104 | FutureWarning,
|
1108 | 1105 | stacklevel=stacklevel,
|
1109 | 1106 | )
|
1110 |
| - assert engine in self._engines, f"Engine {engine} not recognized" |
1111 | 1107 |
|
1112 | 1108 | self.engine = engine
|
1113 | 1109 | self.storage_options = storage_options
|
|
0 commit comments