Python binding for Rust's library for reading excel and odf file - calamine
Actively maintained. Last release 3 days ago, commits in 23 of the last 26 weeks. A safe choice.
pip install python-calaminepython-calamine
Python binding for beautiful Rust's library for reading excel and odf file - calamine.
Is used
Installation
Pypi:
pip install python-calamine
Conda:
conda install -c conda-forge python-calamine
Example
from python_calamine import CalamineWorkbook
workbook = CalamineWorkbook.from_path("file.xlsx")
workbook.sheet_names
# ["Sheet1", "Sheet2"]
workbook.get_sheet_by_name("Sheet1").to_python()
# [
# ["1", "2", "3", "4", "5", "6", "7"],
# ["1", "2", "3", "4", "5", "6", "7"],
# ["1", "2", "3", "4", "5", "6", "7"],
# ]
By default, calamine skips empty rows/cols before data. For suppress this behaviour, set skip_empty_area to False.
from python_calamine import CalamineWorkbook
workbook = CalamineWorkbook.from_path("file.xlsx").get_sheet_by_name("Sheet1").to_python(skip_empty_area=False)
# [
# [", ", ", ", ", ", "],
# ["1", "2", "3", "4", "5", "6", "7"],
# ["1", "2", "3", "4", "5", "6", "7"],
# ["1", "2", "3", "4", "5", "6", "7"],
# ]
Workbook document properties, such as the author, are available for xlsx, xlsb, xls and ods files.
from python_calamine import CalamineWorkbook
properties = CalamineWorkbook.from_path("file.xlsx").workbook_properties
properties.creator
# "John"
properties.last_modified_by
# "Jane"
properties.modified
# datetime.datetime(2024, 6, 20, 14, 22, tzinfo=datetime.timezone.utc)
properties.custom_properties
# {"Department": "Finance"}