Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
msto authored Apr 14, 2024
1 parent fa25463 commit 9b5c619
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ class MyData:
bar: str


with DataclassReader(path, MyData) as reader:
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:
do_something(record.foo)
print(record.foo)
```

### Writing
Expand All @@ -39,7 +44,7 @@ class MyData:
bar: str


with DataclassWriter(path, MyData) as writer:
with DataclassWriter("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 9b5c619

Please sign in to comment.