Skip to main content

A user-friendly Python library for seamless bidirectional conversion between Excel spreadsheets and Pydantic models

Project description

SerializableExcel

Documentation Python Version License

A user-friendly Python library for seamless bidirectional conversion between Excel spreadsheets and Pydantic models using declarative syntax similar to SQLAlchemy.

Quick Start

from serializable_excel import ExcelModel, Column

class UserModel(ExcelModel):
    name: str = Column(header="Name")
    age: int = Column(header="Age")
    email: str = Column(header="Email")

# Read from Excel file
users = UserModel.from_excel("users.xlsx")

# Write to Excel file
UserModel.to_excel(users, "output.xlsx")

# Or work with bytes for API usage
excel_bytes = UserModel.to_excel(users, return_bytes=True)
users = UserModel.from_excel(file_bytes)

Installation

pip install serializable-excel

Or install from source:

git clone https://github.com/of1nn/serializable-excel.git
cd serializable-excel
pip install -r requirements.txt

Features

  • 🔄 Bidirectional Conversion: Seamlessly convert between Excel sheets and Pydantic models
  • 📝 Declarative Syntax: Define models using familiar SQLAlchemy-like syntax
  • 🌐 API Ready: Work with bytes/BytesIO for seamless web API integration (FastAPI, Flask, etc.)
  • 🔍 Automatic Type Inference: Smart type detection from Excel data
  • ✅ Built-in Validation: Automatic validation of data types and constraints
  • 🔧 Dynamic Columns: Support for runtime-detected columns perfect for admin-configurable fields
  • 🛡️ Custom Validators: Define validation functions for data integrity
  • 📤 Custom Getters: Extract values from complex database models when exporting
  • 🎨 Cell Styling: Conditional cell formatting with colors, fonts, and styles
  • 📊 Column Ordering: Control column order in exported Excel files with custom ordering functions

Documentation

📚 Full documentation is available at of1nn.github.io/serializable-excel

The documentation includes:

  • Installation guide
  • Quick start tutorial
  • API reference
  • Advanced usage examples
  • Dynamic columns guide
  • Validation and getters documentation

Requirements

  • Python 3.8 or higher
  • Pydantic 2.x
  • openpyxl (for Excel file handling)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please see our Contributing Guide for details.

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

serializable_excel-0.1.5.tar.gz (25.8 kB view details)

Uploaded Source

Built Distribution

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

serializable_excel-0.1.5-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file serializable_excel-0.1.5.tar.gz.

File metadata

  • Download URL: serializable_excel-0.1.5.tar.gz
  • Upload date:
  • Size: 25.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for serializable_excel-0.1.5.tar.gz
Algorithm Hash digest
SHA256 87ebde32864c97e986c4d854730a291359c33b963653d1e04546bf5f127d6a47
MD5 067c55c0fc1af84751f79a2824c78379
BLAKE2b-256 33f5aef8502518c1e4fe741eac8aa794545206cf3d4156e29c37204f037c8ab4

See more details on using hashes here.

File details

Details for the file serializable_excel-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for serializable_excel-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1fd3d991e77cd642ee158e50a1b2407ae331afd223245f273603ea64203ded01
MD5 14fb78b51f98206dbdb5ddbf117d1c7b
BLAKE2b-256 afcf856a5374a61377b7dd3c6da623ce13f904c470be790f557ac7c90fb6c57c

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