Skip to main content

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

Project description

typeline

PyPi Release CI Python Versions basedpyright mypy Poetry 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:

pip install typeline

Quickstart

Building a Test Dataclass

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

Writing

>>> from tempfile import NamedTemporaryFile
>>> from typeline import TsvStructWriter
>>> 
>>> temp_file = NamedTemporaryFile(mode="w+t", suffix=".txt")
>>>
>>> with TsvStructWriter.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

>>> from typeline import TsvStructReader
>>> 
>>> with TsvStructReader.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 for more information.

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

typeline-0.2.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

typeline-0.2.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file typeline-0.2.0.tar.gz.

File metadata

  • Download URL: typeline-0.2.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for typeline-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d7c73c3b45a5ba573ff52177bfa3caf5e8c7fcce2e47a493ea28adcc377347e2
MD5 36ead19b6d1ee79a8dd67248d524ff27
BLAKE2b-256 2b49f3a55a7e7f0e6a1b0357d8edf340b2d30fd3abce6925607f1544bdbdfb63

See more details on using hashes here.

Provenance

The following attestation bundles were made for typeline-0.2.0.tar.gz:

Publisher: publish_typeline.yml on clintval/typeline

Attestations:

File details

Details for the file typeline-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: typeline-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for typeline-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ac06a31c6cd080d796033de945d4c2f1bbb700f27c45d0bea854a1f98c1aa8a
MD5 c258362bee238f5b177cc0dfb85d6649
BLAKE2b-256 940ec94617803af932af8eb19c6d16c4bf953eb7f2484bce021b2edf9e248094

See more details on using hashes here.

Provenance

The following attestation bundles were made for typeline-0.2.0-py3-none-any.whl:

Publisher: publish_typeline.yml on clintval/typeline

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page