typeline


Nametypeline JSON
Version 0.7.0 PyPI version JSON
download
home_pagehttps://github.com/clintval/typeline
SummaryWrite dataclasses to delimited text formats and read them back again.
upload_time2024-11-14 17:03:11
maintainerNone
docs_urlNone
authorClint Valentine
requires_python<4.0.0,>=3.10.0
licenseMIT
keywords dataclass msgspec io delimited csv tsv
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # typeline

[![PyPi Release](https://badge.fury.io/py/typeline.svg)](https://badge.fury.io/py/typeline)
[![CI](https://github.com/clintval/typeline/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/clintval/typeline/actions/workflows/tests.yml?query=branch%3Amain)
[![Python Versions](https://img.shields.io/badge/python-3.10_|_3.11_|_3.12-blue)](https://github.com/clintval/typeline)
[![basedpyright](https://img.shields.io/badge/basedpyright-checked-42b983)](https://docs.basedpyright.com/latest/)
[![mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)
[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://docs.astral.sh/ruff/)

Write dataclasses to delimited text formats and read them back again.

Features type-safe parsing, optional field support, and an intuitive API for working with structured data.

## Installation

The package can be installed with `pip`:

```console
pip install typeline
```

## Quickstart

### Building a Test Dataclass

```pycon
>>> from dataclasses import dataclass
>>>
>>> @dataclass
... class MyData:
...     field1: int
...     field2: str
...     field3: float | None

```

### Writing

```pycon
>>> from tempfile import NamedTemporaryFile
>>> from typeline import TsvRecordWriter
>>> 
>>> temp_file = NamedTemporaryFile(mode="w+t", suffix=".txt")
>>>
>>> with TsvRecordWriter.from_path(temp_file.name, MyData) as writer:
...     writer.write_header()
...     writer.write(MyData(10, "test1", 0.2))
...     writer.write(MyData(20, "test2", None))

```

### Reading

```pycon
>>> from typeline import TsvRecordReader
>>> 
>>> with TsvRecordReader.from_path(temp_file.name, MyData) as reader:
...     for record in reader:
...         print(record)
MyData(field1=10, field2='test1', field3=0.2)
MyData(field1=20, field2='test2', field3=None)

```

## Development and Testing

See the [contributing guide](./CONTRIBUTING.md) for more information.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/clintval/typeline",
    "name": "typeline",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0.0,>=3.10.0",
    "maintainer_email": null,
    "keywords": "dataclass, msgspec, IO, delimited, CSV, TSV",
    "author": "Clint Valentine",
    "author_email": "valentine.clint@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/88/cb/ae66fee23e2110dea9cad525ce43fa94eba7e79f3b90cf46deb4f5879bc2/typeline-0.7.0.tar.gz",
    "platform": null,
    "description": "# typeline\n\n[![PyPi Release](https://badge.fury.io/py/typeline.svg)](https://badge.fury.io/py/typeline)\n[![CI](https://github.com/clintval/typeline/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/clintval/typeline/actions/workflows/tests.yml?query=branch%3Amain)\n[![Python Versions](https://img.shields.io/badge/python-3.10_|_3.11_|_3.12-blue)](https://github.com/clintval/typeline)\n[![basedpyright](https://img.shields.io/badge/basedpyright-checked-42b983)](https://docs.basedpyright.com/latest/)\n[![mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)\n[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://docs.astral.sh/ruff/)\n\nWrite dataclasses to delimited text formats and read them back again.\n\nFeatures type-safe parsing, optional field support, and an intuitive API for working with structured data.\n\n## Installation\n\nThe package can be installed with `pip`:\n\n```console\npip install typeline\n```\n\n## Quickstart\n\n### Building a Test Dataclass\n\n```pycon\n>>> from dataclasses import dataclass\n>>>\n>>> @dataclass\n... class MyData:\n...     field1: int\n...     field2: str\n...     field3: float | None\n\n```\n\n### Writing\n\n```pycon\n>>> from tempfile import NamedTemporaryFile\n>>> from typeline import TsvRecordWriter\n>>> \n>>> temp_file = NamedTemporaryFile(mode=\"w+t\", suffix=\".txt\")\n>>>\n>>> with TsvRecordWriter.from_path(temp_file.name, MyData) as writer:\n...     writer.write_header()\n...     writer.write(MyData(10, \"test1\", 0.2))\n...     writer.write(MyData(20, \"test2\", None))\n\n```\n\n### Reading\n\n```pycon\n>>> from typeline import TsvRecordReader\n>>> \n>>> with TsvRecordReader.from_path(temp_file.name, MyData) as reader:\n...     for record in reader:\n...         print(record)\nMyData(field1=10, field2='test1', field3=0.2)\nMyData(field1=20, field2='test2', field3=None)\n\n```\n\n## Development and Testing\n\nSee the [contributing guide](./CONTRIBUTING.md) for more information.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Write dataclasses to delimited text formats and read them back again.",
    "version": "0.7.0",
    "project_urls": {
        "Homepage": "https://github.com/clintval/typeline",
        "Repository": "https://github.com/clintval/typeline"
    },
    "split_keywords": [
        "dataclass",
        " msgspec",
        " io",
        " delimited",
        " csv",
        " tsv"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7665d41759d7798fc0ec9fd723936d53553d4014393fc2a6f2371e16c9eaa842",
                "md5": "13d41b72d483c94a231e79ec8dcfdaad",
                "sha256": "2f9ccdccde7c0fa1d07bb1c7cede1ae9e4592b12666fae4d39ca8145b90c5bdb"
            },
            "downloads": -1,
            "filename": "typeline-0.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "13d41b72d483c94a231e79ec8dcfdaad",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0.0,>=3.10.0",
            "size": 10570,
            "upload_time": "2024-11-14T17:03:10",
            "upload_time_iso_8601": "2024-11-14T17:03:10.250631Z",
            "url": "https://files.pythonhosted.org/packages/76/65/d41759d7798fc0ec9fd723936d53553d4014393fc2a6f2371e16c9eaa842/typeline-0.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "88cbae66fee23e2110dea9cad525ce43fa94eba7e79f3b90cf46deb4f5879bc2",
                "md5": "0e4c3c1afdb7f819240fb4f10d391070",
                "sha256": "2c4b692189dd655bbf42b6137166b9cae2e5567a2cee3eb27f895b32aaadd4b7"
            },
            "downloads": -1,
            "filename": "typeline-0.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0e4c3c1afdb7f819240fb4f10d391070",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0.0,>=3.10.0",
            "size": 9579,
            "upload_time": "2024-11-14T17:03:11",
            "upload_time_iso_8601": "2024-11-14T17:03:11.873248Z",
            "url": "https://files.pythonhosted.org/packages/88/cb/ae66fee23e2110dea9cad525ce43fa94eba7e79f3b90cf46deb4f5879bc2/typeline-0.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-14 17:03:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "clintval",
    "github_project": "typeline",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "typeline"
}
        
Elapsed time: 0.38040s