python-calamine
python-calamine is a Python binding for the Rust library 'calamine', designed for fast reading of Excel (.xlsx, .xls, .xlsb) and ODF (.ods) spreadsheet files. It is actively maintained, with version 0.6.2 released in February 2026, indicating a regular release cadence.
Warnings
- gotcha Calamine does not perform implicit data type conversions for numbers and may change strings into numbers, which can lead to unexpected data types if not handled explicitly. Excel numbers are read as floats.
- gotcha By default, `python-calamine` skips empty rows/columns before the actual data area. This might lead to unexpected results if leading empty cells are significant.
- gotcha Some users reported performance degradation when reading data over VPN network connections starting from version 0.2.3.
- gotcha Issues have been reported where the first two columns in old `.xls` files are read incorrectly.
- deprecated For `pandas` versions 2.0 and 2.1, using `python-calamine` as an engine for `read_excel` required a monkeypatch.
Install
-
pip install python-calamine -
conda install -c conda-forge python-calamine
Imports
- CalamineWorkbook
from python_calamine import CalamineWorkbook
Quickstart
import os
from python_calamine import CalamineWorkbook
# Create a dummy Excel file for demonstration
# In a real scenario, 'file.xlsx' would already exist.
# For this quickstart, we'll simulate reading a file.
# You would replace 'file.xlsx' with your actual file path.
# Placeholder for creating a file, as we cannot write to disk directly in this environment.
# Assume 'dummy_file.xlsx' exists with at least one sheet named 'Sheet1'
# and some data like [['1', '2', '3'], ['4', '5', '6']].
try:
# Attempt to open a non-existent file to demonstrate error handling
# In a real application, ensure the file exists.
workbook = CalamineWorkbook.from_path('dummy_file.xlsx')
print(f"Sheet names: {workbook.sheet_names}")
# Get data from the first sheet
if workbook.sheet_names:
sheet_data = workbook.get_sheet_by_name(workbook.sheet_names[0]).to_python()
print(f"Data from '{workbook.sheet_names[0]}': {sheet_data}")
# Example with skipping empty areas (default is True)
# To suppress this, set skip_empty_area=False
# sheet_data_with_empty = workbook.get_sheet_by_name(workbook.sheet_names[0]).to_python(skip_empty_area=False)
# print(f"Data (including empty): {sheet_data_with_empty}")
except FileNotFoundError:
print("Please ensure 'dummy_file.xlsx' exists in the current directory or provide a valid path.")
print("For example, create a simple Excel file with content and try again.")
except Exception as e:
print(f"An error occurred: {e}")