Dataclass IO
Project description
dataclass_io
Dataclass IO.
Quickstart
Reading
from dataclasses import dataclass
from dataclass_io import DataclassReader
@dataclass
class MyData:
foo: int
bar: str
with open("test.tsv", "w") as testfile:
testfile.write("foo\tbar\n")
testfile.write("1\tabc\n")
testfile.write("2\tdef\n")
with DataclassReader("test.tsv", MyData) as reader:
for record in reader:
print(record.foo)
Writing
from dataclasses import dataclass
from dataclass_io import DataclassWriter
@dataclass
class MyData:
foo: int
bar: str
with DataclassWriter("test.tsv", MyData) as writer:
for i in range(3):
record = MyData(foo=i, bar="something")
writer.write(record)
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
dataclass_io-0.1.0.tar.gz
(8.0 kB
view hashes)
Built Distribution
Close
Hashes for dataclass_io-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec833815e15dc1c4196c3cdbd0ec693c6e8893915440288b3c42ddc0cba8590c |
|
MD5 | c1cb71df2dfc6cdd6a84a03bc8c930c7 |
|
BLAKE2b-256 | 45699fac69a800d57838cce77ae6f3f97dc8a70e916af558563e798943efc65e |