A user-friendly Python library for seamless bidirectional conversion between Excel spreadsheets and Pydantic models
Project description
SerializableExcel
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
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
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 serializable_excel-0.1.3.tar.gz.
File metadata
- Download URL: serializable_excel-0.1.3.tar.gz
- Upload date:
- Size: 21.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c17452bd43131e72d1cc0583c50e943cae7af5ebb515f7d903cdb87029d5bbe1
|
|
| MD5 |
69c6b1ed120033620b4d4cee3e680891
|
|
| BLAKE2b-256 |
7da851c1f7ed9017ab9352bb9412ed879798aeadd1a0fdd717d51d209bd3713a
|
File details
Details for the file serializable_excel-0.1.3-py3-none-any.whl.
File metadata
- Download URL: serializable_excel-0.1.3-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d01b1d325a723941a2990f86c8495f88fd980fe5b3d1c20cfc733fdaa8b000c3
|
|
| MD5 |
783e42a543a36eb933110535b668ffcb
|
|
| BLAKE2b-256 |
b648fca8379e5fc39629712241c2019fdac8cdc4a018b85f03c793616d454d65
|