Skip to main content

Reducto fork of python-calamine — Python binding for calamine (Rust xlsx/xls/ods reader) with CellGrid, Rust SSF formatting, and style bindings

Project description

python-calamine (Reducto fork)

Private fork of python-calamine with CellGrid, style/layout bindings, and performance optimizations for spreadsheet processing.

Provenance

dimastbk/python-calamine (upstream, v0.6.1)
  └─ reductoai/python-calamine (this repo — CellGrid + style/layout bindings)

The upstream/master branch is a frozen snapshot of dimastbk's code. Our additions live on main.

What we added

Style & layout bindings (workbook.rs)

  • get_sheet_styles(name) → list of (row, col, style_dict) tuples
    • Font: bold, italic, size, color, name, underline, strikethrough
    • Fill: pattern, fg_color, bg_color
    • Borders: top, bottom, left, right styles
    • Number format string
  • get_sheet_layout(name) → dict with row heights, column widths, defaults
  • get_sheet_bounds(name)(max_filled_row, max_filled_col) computed in Rust
  • get_sheet_grid(name, rows, cols, include_styles=True)CellGrid (builds entire grid in a single Rust call)

CellGrid (grid.rs) — Rust-backed 2D grid

Replaces numpy structured arrays. All cell data stays in Rust Vecs and only crosses to Python on demand.

Types:

  • CellGrid — the main 2D grid (values, styles, merges, header, colors, formulas)
  • CellProxy — lightweight single-cell accessor (supports cell.value and cell["value"])
  • CellGridView — zero-copy sub-grid view for slicing

Access patterns:

  • grid[r, c]CellProxy
  • grid[r1:r2, c1:c2]CellGridView
  • grid["field_name"] → numpy 2D array of that field
  • grid["field_name"] = value → broadcast or copy from numpy

Grid operations:

  • vstack(other) / hstack(other) — concatenation
  • slice_copy(r1, r2, c1, c2) — independent copy of region
  • copy() — deep copy
  • CellGrid.empty(rows, cols) — create empty grid
  • masked_copy_from(source, mask, ...) — boolean mask copy

Formatting:

  • apply_formatting(callback) — calls Python SSF per cell
  • apply_raw_as_formatted()str(raw) for large sheets

Performance

File openpyxl calamine + CellGrid Speedup
7 MB, 26k cells 711ms 256ms 2.8x
22 MB, 4.2M cells 491s 8.2s 60x

Calamine dependency

This repo depends on reductoai/calamine (our private fork with styles):

# Cargo.toml
calamine = { git = "https://github.com/reductoai/calamine", branch = "main", features = ["chrono"] }

For local development, override with a path dep:

calamine = { path = "../calamine", features = ["chrono"] }

Syncing with upstream

git fetch upstream  # upstream = dimastbk/python-calamine
git merge upstream/master
# Resolve Cargo.toml conflict: keep our git dep for calamine

Key files

File What
src/types/grid.rs CellGrid, CellProxy, CellGridView
src/types/workbook.rs get_sheet_grid, get_sheet_styles, get_sheet_layout
src/types/sheet.rs CalamineSheet, CalamineCellIterator
src/types/cell.rs CellValue enum → Python type conversion
src/lib.rs PyO3 module registration
python/python_calamine/__init__.py Python re-exports

python-calamine

Python binding for Rust's calamine library for reading Excel and ODF files.

Built with

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"],
# ]

Development

Prerequisites

  • Rust toolchain (rustup)
  • Python 3.10+
  • maturin (pip install maturin)

Build

git clone git@github.com:reductoai/python-calamine.git
cd python-calamine

# Create venv (or use existing one)
python3 -m venv .venv && source .venv/bin/activate

# Build and install into venv
maturin develop --release    # ~4s incremental, ~30s clean

# Or build into a specific venv (e.g. api4's):
/path/to/api4/.venv/bin/maturin develop --release

Workflow for Rust changes

  1. Edit files in src/types/
  2. Run maturin develop --release
  3. Test in Python — the venv's python_calamine package is updated in-place

Credits

Thanks to dimastbk for the original python-calamine bindings.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

python_calamine_reducto-0.7.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

python_calamine_reducto-0.7.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

python_calamine_reducto-0.7.0-cp313-cp313-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

python_calamine_reducto-0.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

python_calamine_reducto-0.7.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

python_calamine_reducto-0.7.0-cp312-cp312-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

python_calamine_reducto-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

python_calamine_reducto-0.7.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

python_calamine_reducto-0.7.0-cp311-cp311-macosx_11_0_arm64.whl (22.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file python_calamine_reducto-0.7.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for python_calamine_reducto-0.7.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1449423f2b31bf7bbfbdc2c8d1481aeca8f0d8495bbc8cb8a4cc7eabdd528ddb
MD5 a3ee0482d5f1e7ad44ace90e1bf3ba53
BLAKE2b-256 f86301ed213ac72d9c9e87c88049f37c3f78bc2f2afc868e730cc04d76026cae

See more details on using hashes here.

File details

Details for the file python_calamine_reducto-0.7.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for python_calamine_reducto-0.7.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a9cddfc90e27afa5c3ea8ec83ccefd071c31d47207fe8461f0bcb9b959d47b3e
MD5 d01ca9b60427542f474ae0a3af53955b
BLAKE2b-256 5aa2251a58fd17a794d81fc709e667bb50afe7c2da9748da7415528378592ba6

See more details on using hashes here.

File details

Details for the file python_calamine_reducto-0.7.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for python_calamine_reducto-0.7.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 083e2b42f19d4e0a92022360a673e7a41e81ba43e46171998ab9c3f6550aaf94
MD5 073d255850243dd4c3ccce864515ea7e
BLAKE2b-256 ee6c4ad2c150987cf5cf0f7db406d4720f4bf098a7593df7762f85c634270eda

See more details on using hashes here.

File details

Details for the file python_calamine_reducto-0.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for python_calamine_reducto-0.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4ce1073895e7757afcd04aa673de4e2375b8e3d1ee7f8cba7f1fcadb2bbff04f
MD5 78961c7b59e143830a708b9316330004
BLAKE2b-256 632081c80eba5dcbb48523d2f5c65e6466fee567c952301ba9b705d11ad77c59

See more details on using hashes here.

File details

Details for the file python_calamine_reducto-0.7.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for python_calamine_reducto-0.7.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f7c84ab0d971b0c817f3a75508a4f627f2f5af50b45561ca50706bfa8a672a62
MD5 af8d5157695776b91bd5d75aac0057e9
BLAKE2b-256 a914004a0e5492267603e396f322fdf7681e94b39adbbdf0f902462a55967231

See more details on using hashes here.

File details

Details for the file python_calamine_reducto-0.7.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for python_calamine_reducto-0.7.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e7c58b27d074ad5d072426d85cc4e0a74465ed2725b3346f666a5a4a313b4718
MD5 cc1974af6a4065aad6ef70e28113a453
BLAKE2b-256 f5c2f64c227d9e4f66242e5788b9a402f04bc4d42f0da3440dbef6afa0b1f459

See more details on using hashes here.

File details

Details for the file python_calamine_reducto-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for python_calamine_reducto-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 757aede78baa67576d9c4059d2150b751dbc522d9275005a509238e2c9ed0b37
MD5 4f38a0dd42de244fc74cfb942e5b3e1c
BLAKE2b-256 987954944e17e8f80c26ebcb8248a8db02c8b437b80f6388c680a915a47774b0

See more details on using hashes here.

File details

Details for the file python_calamine_reducto-0.7.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for python_calamine_reducto-0.7.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8a4eb4626b010b50f44ef91ad36b75855481f7edf2bf44a3cb72a5c9733d2ffe
MD5 b2db63d6e35af82293f4abc99ee0beda
BLAKE2b-256 9d5d2955c938540b2f76b91f14235c3d8f759ac4a0da16f5ac185c96e29435dc

See more details on using hashes here.

File details

Details for the file python_calamine_reducto-0.7.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for python_calamine_reducto-0.7.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b058307670913074186505e43b5f2ec92b76ac6300d455df102a16f41610b6b3
MD5 edfb3a5c4d421008efabc27997c7525d
BLAKE2b-256 87dedfb79eab29f25c863a248630a89331123bd09b993404677ead5852edbbb5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page