Skip to main content

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 .xlsx reading
  • 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 .xlsx file
  • max_memory_mb: (Optional) Max memory in MB. If exceeded, function returns whatever is collected so far
  • char_limit: (Optional) For preview function — default is 3000

📂 How It Works

  • Unzips .xlsx files using Python's zipfile
  • Parses XML content with ElementTree
  • Looks for:
    • xl/sharedStrings.xml for global text
    • xl/worksheets/sheet*.xml for cell values

🛡️ Memory Safety

  • Uses psutil to 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


Download files

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

Source Distribution

xlsxlean-0.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

xlsxlean-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

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

Hashes for xlsxlean-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a7f76e0d8f8557432dde13179950e43555c3cbe1eb7abe8df0f310d2131bc4ec
MD5 daf25d081b38eac96e52333a15b4582d
BLAKE2b-256 8d47bbe8275ed11b66008b14ad49f191c316f5ab206f879fbeb4db6f8654ce77

See more details on using hashes here.

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

Hashes for xlsxlean-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 084bf977f0c9009e60d21141db78c2b4dee1dcbc3191f86acd1f5ab73711f2c8
MD5 7fa080587fcaf1e980f2b1b783c2eff9
BLAKE2b-256 7c4173afed0f2034f3b9978b57ce15c8667f7151d649f116953c96b00abad453

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