Skip to content

Commit

Permalink
Update README.md (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
msto committed Sep 5, 2024
1 parent 13c8132 commit 79ad7ad
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
[![MyPy Checked](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://docs.astral.sh/ruff/)

Dataclass IO.
Read and write dataclasses.

`dataclass_io` provides similar functionality to the standard library's `csv.DictReader` and `csv.DictWriter`, and adds type safety.

## Installation

Expand Down Expand Up @@ -35,7 +37,7 @@ with open("test.tsv", "w") as testfile:
testfile.write("1\tabc\n")
testfile.write("2\tdef\n")

with DataclassReader("test.tsv", MyData) as reader:
with DataclassReader.open("test.tsv", MyData) as reader:
for record in reader:
print(record.foo)
```
Expand All @@ -52,7 +54,7 @@ class MyData:
bar: str


with DataclassWriter("test.tsv", MyData) as writer:
with DataclassWriter.open("test.tsv", MyData) as writer:
for i in range(3):
record = MyData(foo=i, bar="something")
writer.write(record)
Expand Down

0 comments on commit 79ad7ad

Please sign in to comment.