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.1.tar.gz
(3.2 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.1.tar.gz.
File metadata
- Download URL: pydanticio-0.3.1.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1a8b0dc2c8e6923d5e968c78854fd200db2742f2c0c8aeb162b297f9aded950
|
|
| MD5 |
252de257402743385825710f814b98e8
|
|
| BLAKE2b-256 |
e124fc609079a1c293272c703c87b8977fec7335a0fa65a5457a2c14c343f235
|
File details
Details for the file pydanticio-0.3.1-py3-none-any.whl.
File metadata
- Download URL: pydanticio-0.3.1-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 |
dde3c2babe6d04e07b85dcefda6b5f4e4bbcf4d6b203eef37983c8808cc5c5b8
|
|
| MD5 |
801091517de40bdaa022376dfedf985b
|
|
| BLAKE2b-256 |
5be8a9830ce80874512735a3c3cabc699039cc1789cfb0dc78b8b6ef7d35c247
|