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 TsvWriter
>>>
>>> temp_file = NamedTemporaryFile(mode="w+t", suffix=".tsv")
>>>
>>> with TsvWriter.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 TsvReader
>>>
>>> with TsvReader.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
Release history Release notifications | RSS feed
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.11.0.tar.gz
(8.8 kB
view details)
File details
Details for the file typeline-0.11.0.tar.gz.
File metadata
- Download URL: typeline-0.11.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8e3f6ac130dde590e8172f6d92c45badbc04fc1aa5cf47b92f8e8632f2fc6a4
|
|
| MD5 |
25f9f4aa50fd30da8220e37b7e6623cb
|
|
| BLAKE2b-256 |
93dc138f63e751c0f0a2cdae6ac81ed59914893b9b4951cdde0bcd37c5763277
|
Provenance
The following attestation bundles were made for typeline-0.11.0.tar.gz:
Publisher:
publish_typeline.yml on clintval/typeline
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typeline-0.11.0.tar.gz -
Subject digest:
a8e3f6ac130dde590e8172f6d92c45badbc04fc1aa5cf47b92f8e8632f2fc6a4 - Sigstore transparency entry: 200370763
- Sigstore integration time:
-
Permalink:
clintval/typeline@647199a46e6227b11a9b686d18ef466b8360b177 -
Branch / Tag:
refs/tags/0.11.0 - Owner: https://github.com/clintval
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_typeline.yml@647199a46e6227b11a9b686d18ef466b8360b177 -
Trigger Event:
push
-
Statement type: