A Tiny file IO utility library for Python powered by Pydantic
Project description
PydanticIO
PydanticIO (pronounce pidantisio) is a tiny file IO utility library for Python powered by Pydantic. This library is a port of the Rust library SerdeIO
Install
# standard distribution
pip install pydanticio
# with YAML backend
pip install pydanticio[yaml]
Supported Formats
- CSV by stdlib
csvmodule - JSON by stdlib
jsonmodule - JSON Lines by stdlib
jsonmodule - YAML by
pyyamllibrary, it is an optional feature and you need enable it manually at when you install it.
Usage
read_record_from_readeris used to read a typeTwhich is a subclass ofpydantic.BaseModelfromTextIO. Data format must be specified byDataFormatliterals.read_records_from_readeralways tries to deserialize the data aslist[T].read_record_from_fileandread_records_from_fileaccepts aPath. Data format is automatically determined by file extension.write_*functions follow the same rules asread_*.
Note that some data format like CSV and JSON Lines support only reading records list[T].
Examples
from pydantic import BaseModel
from pydanticio import read_records_from_file, write_records_to_file
class User(BaseModel):
name: str
age: int
users = read_records_from_file("users.csv", User)
write_records_to_file("users.json", users)
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
pydanticio-0.3.0.tar.gz
(3.3 kB
view details)
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 pydanticio-0.3.0.tar.gz.
File metadata
- Download URL: pydanticio-0.3.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca7b4c64b0bfd33b5b6982df6b85d305d67c8d58c7aa156adff427a61378fc39
|
|
| MD5 |
3c9f64b07bd75e456d2b4bc4defa9b1c
|
|
| BLAKE2b-256 |
c012324303a9cf091309b59cc0f37aa11bd423d275df1ecd1e869d1a19056817
|
File details
Details for the file pydanticio-0.3.0-py3-none-any.whl.
File metadata
- Download URL: pydanticio-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5274daba3ed344bd42ab7f37a7566f229a6273773d34e83f930c1f230715eb7c
|
|
| MD5 |
7ee23886b88a4752633be30c8e4c6018
|
|
| BLAKE2b-256 |
0ce9aa1d520ae2e39d5a16bafbaf13fbe913aeb84e661d089b26b385b151c646
|