I want to use pandas.read_excel
to read an Excel file with the option engine="openpyxl"
. However, I also want to pass additional optimization options to openpyxl
such as:
read_only=True
data_only=True
keep_links=False
How do I do this?
These are already implemented by default. From version 2.2:
def load_workbook(
self, filepath_or_buffer: FilePath | ReadBuffer[bytes], engine_kwargs
) -> Workbook:
from openpyxl import load_workbook
default_kwargs = {"read_only": True, "data_only": True, "keep_links": False}
return load_workbook(
filepath_or_buffer,
**(default_kwargs | engine_kwargs),
)