pydanticio


Namepydanticio JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryA Tiny file IO utility library for Python powered by Pydantic
upload_time2024-06-30 11:36:10
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseMIT
keywords file io library pydantic utility
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://github.com/lucidfrontier45/serdeio)

# Install

```sh
# standard distribution
pip install pydanticio

# with YAML backend
pip install pydanticio[yaml]
```

# Supported Formats

- CSV by stdlib `csv` module
- JSON by stdlib `json` module
- JSON Lines by stdlib `json` module
- YAML by `pyyaml` library, it is an optional feature and you need enable it manually at when you install it.

# Usage

- `read_record_from_reader` is used to read a type `T` which is a subclass of `pydantic.BaseModel` from `TextIO`. Data format must be specified by `DataFormat` literals.
- `read_records_from_reader` always tries to deserialize the data as `list[T]`.
- `read_record_from_file` and `read_records_from_file` accepts a `Path`. Data format is automatically determined by file extension.
- `write_*` functions follow the same rules as `read_*`.

Note that some data format like CSV and JSON Lines support only reading records `list[T]`.

# Examples

```py
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)
```
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pydanticio",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "file, io, library, pydantic, utility",
    "author": null,
    "author_email": "\u675c\u4e16\u6a4b Du Shiqiao <lucidfrontier.45@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/bc/fd/0772e4d9cf9c62d095ecb6a58f1b32802835d68ce7401b510f69182e856a/pydanticio-0.2.0.tar.gz",
    "platform": null,
    "description": "# PydanticIO\n\nPydanticIO (pronounce pidantisio) is a tiny file IO utility library for Python powered by Pydantic.\nThis library is a port of the Rust library [SerdeIO](https://github.com/lucidfrontier45/serdeio)\n\n# Install\n\n```sh\n# standard distribution\npip install pydanticio\n\n# with YAML backend\npip install pydanticio[yaml]\n```\n\n# Supported Formats\n\n- CSV by stdlib `csv` module\n- JSON by stdlib `json` module\n- JSON Lines by stdlib `json` module\n- YAML by `pyyaml` library, it is an optional feature and you need enable it manually at when you install it.\n\n# Usage\n\n- `read_record_from_reader` is used to read a type `T` which is a subclass of `pydantic.BaseModel` from `TextIO`. Data format must be specified by `DataFormat` literals.\n- `read_records_from_reader` always tries to deserialize the data as `list[T]`.\n- `read_record_from_file` and `read_records_from_file` accepts a `Path`. Data format is automatically determined by file extension.\n- `write_*` functions follow the same rules as `read_*`.\n\nNote that some data format like CSV and JSON Lines support only reading records `list[T]`.\n\n# Examples\n\n```py\nfrom pydantic import BaseModel\nfrom pydanticio import read_records_from_file, write_records_to_file\n\nclass User(BaseModel):\n    name: str\n    age: int\n\n\nusers = read_records_from_file(\"users.csv\", User)\nwrite_records_to_file(\"users.json\", users)\n```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Tiny file IO utility library for Python powered by Pydantic",
    "version": "0.2.0",
    "project_urls": {
        "repository": "https://github.com/lucidfrontier45/pydanticio"
    },
    "split_keywords": [
        "file",
        " io",
        " library",
        " pydantic",
        " utility"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2cc6277c7b214a8812c964dc3f4b37652d69a9bd066008234218a31050397e5a",
                "md5": "763920c50416e84c61e5777638c89c5e",
                "sha256": "810b3f24b1fb1fc718727a9348b213e0534aa0014ef6549b69c89622c6e92e78"
            },
            "downloads": -1,
            "filename": "pydanticio-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "763920c50416e84c61e5777638c89c5e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 5913,
            "upload_time": "2024-06-30T11:36:05",
            "upload_time_iso_8601": "2024-06-30T11:36:05.472823Z",
            "url": "https://files.pythonhosted.org/packages/2c/c6/277c7b214a8812c964dc3f4b37652d69a9bd066008234218a31050397e5a/pydanticio-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bcfd0772e4d9cf9c62d095ecb6a58f1b32802835d68ce7401b510f69182e856a",
                "md5": "416319843182471cecd837555ef93cf8",
                "sha256": "b430279174380e2e53ea5ed931697bfa82cfeeca80ea2b4fa337eb29cea5f2da"
            },
            "downloads": -1,
            "filename": "pydanticio-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "416319843182471cecd837555ef93cf8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 6504,
            "upload_time": "2024-06-30T11:36:10",
            "upload_time_iso_8601": "2024-06-30T11:36:10.161284Z",
            "url": "https://files.pythonhosted.org/packages/bc/fd/0772e4d9cf9c62d095ecb6a58f1b32802835d68ce7401b510f69182e856a/pydanticio-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-30 11:36:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lucidfrontier45",
    "github_project": "pydanticio",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pydanticio"
}
        
Elapsed time: 0.86029s