Minimal memory XLSX reader with safe preview and full content options
Project description
xlsxlean
xlsxlean is a lightweight Python package that reads .xlsx (Excel) files using minimal memory. It is ideal for memory-constrained environments or scenarios where Excel files might be large or potentially malformed.
🚀 Features
- Memory-safe
.xlsxreading - Read entire content or just a preview (e.g., 3000 characters)
- Automatically parses shared strings and inline values
- Graceful fallback when memory usage exceeds a threshold
- No need for pandas or openpyxl
- Fast and portable — perfect for backend scripts and CLI tools
📦 Installation
pip install xlsxlean
🧪 Usage
Import the Reader
from xlsxlean.reader import read_xlsx_full_content, read_xlsx_preview_3000_chars
Read Entire XLSX File
content = read_xlsx_full_content("example.xlsx", max_memory_mb=2048)
print(content)
Read First 3000 Characters
preview = read_xlsx_preview_3000_chars("example.xlsx")
print(preview)
⚙️ Parameters
filepath: Path to.xlsxfilemax_memory_mb: (Optional) Max memory in MB. If exceeded, function returns whatever is collected so farchar_limit: (Optional) For preview function — default is 3000
📂 How It Works
- Unzips
.xlsxfiles using Python'szipfile - Parses XML content with
ElementTree - Looks for:
xl/sharedStrings.xmlfor global textxl/worksheets/sheet*.xmlfor cell values
🛡️ Memory Safety
- Uses
psutilto monitor memory usage - If memory exceeds
max_memory_mb, function stops and returns collected content
🔧 Requirements
- Python 3.6+
psutil(installed automatically)
📄 License
MIT License. See LICENSE file for details.
✍️ Author
Animesh Ranjan
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xlsxlean-0.1.0.tar.gz.
File metadata
- Download URL: xlsxlean-0.1.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7f76e0d8f8557432dde13179950e43555c3cbe1eb7abe8df0f310d2131bc4ec
|
|
| MD5 |
daf25d081b38eac96e52333a15b4582d
|
|
| BLAKE2b-256 |
8d47bbe8275ed11b66008b14ad49f191c316f5ab206f879fbeb4db6f8654ce77
|
File details
Details for the file xlsxlean-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xlsxlean-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
084bf977f0c9009e60d21141db78c2b4dee1dcbc3191f86acd1f5ab73711f2c8
|
|
| MD5 |
7fa080587fcaf1e980f2b1b783c2eff9
|
|
| BLAKE2b-256 |
7c4173afed0f2034f3b9978b57ce15c8667f7151d649f116953c96b00abad453
|