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 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
>>> 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 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.7.0.tar.gz
.
File metadata
- Download URL: typeline-0.7.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c4b692189dd655bbf42b6137166b9cae2e5567a2cee3eb27f895b32aaadd4b7 |
|
MD5 | 0e4c3c1afdb7f819240fb4f10d391070 |
|
BLAKE2b-256 | 88cbae66fee23e2110dea9cad525ce43fa94eba7e79f3b90cf46deb4f5879bc2 |
Provenance
The following attestation bundles were made for typeline-0.7.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.7.0.tar.gz
- Subject digest:
2c4b692189dd655bbf42b6137166b9cae2e5567a2cee3eb27f895b32aaadd4b7
- Sigstore transparency entry: 148923577
- Sigstore integration time:
- Predicate type:
File details
Details for the file typeline-0.7.0-py3-none-any.whl
.
File metadata
- Download URL: typeline-0.7.0-py3-none-any.whl
- Upload date:
- Size: 10.6 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 | 2f9ccdccde7c0fa1d07bb1c7cede1ae9e4592b12666fae4d39ca8145b90c5bdb |
|
MD5 | 13d41b72d483c94a231e79ec8dcfdaad |
|
BLAKE2b-256 | 7665d41759d7798fc0ec9fd723936d53553d4014393fc2a6f2371e16c9eaa842 |
Provenance
The following attestation bundles were made for typeline-0.7.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.7.0-py3-none-any.whl
- Subject digest:
2f9ccdccde7c0fa1d07bb1c7cede1ae9e4592b12666fae4d39ca8145b90c5bdb
- Sigstore transparency entry: 148923579
- Sigstore integration time:
- Predicate type: