Write dataclasses to delimited text formats and read them back again.
Project description
typeline
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
Built Distribution
File details
Details for the file typeline-0.1.0.tar.gz
.
File metadata
- Download URL: typeline-0.1.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 084ce7636520ded77d40156859687bdf7169c0bbc30dc2110c052690737cea5d |
|
MD5 | d51cc4dc23fb849f2527b0485f031d67 |
|
BLAKE2b-256 | 3f6768c5ef3f4fcd3bd8db45d0cdcf32ea7336852b0ee70a287aa288a1e5d791 |
Provenance
The following attestation bundles were made for typeline-0.1.0.tar.gz
:
Publisher:
publish_typeline.yml
on clintval/typeline
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
typeline-0.1.0.tar.gz
- Subject digest:
084ce7636520ded77d40156859687bdf7169c0bbc30dc2110c052690737cea5d
- Sigstore transparency entry: 147654222
- Sigstore integration time:
- Predicate type:
File details
Details for the file typeline-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: typeline-0.1.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf56e9386f225ea8689ba3cae8085bfd1488e36748452efe2fd49e44d02836ca |
|
MD5 | bdfd8e1985d92eea98690363e275e597 |
|
BLAKE2b-256 | 7742dc5bd2b32b4de3394346faa488f850539bb807b07f0588f2c82bf325d8ee |
Provenance
The following attestation bundles were made for typeline-0.1.0-py3-none-any.whl
:
Publisher:
publish_typeline.yml
on clintval/typeline
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
typeline-0.1.0-py3-none-any.whl
- Subject digest:
bf56e9386f225ea8689ba3cae8085bfd1488e36748452efe2fd49e44d02836ca
- Sigstore transparency entry: 147654223
- Sigstore integration time:
- Predicate type: