mirror of
https://github.com/Unstructured-IO/unstructured.git
synced 2025-10-04 21:03:31 +00:00

* Implement save_as_jsonl and read_from_jsonl utility functions * Add unit tests for save_as_jsonl and read_from_jsonl utility functions * Add example of using save_as_jsonl with prodigy staging brick * Bump version and update changelog * remove accidentally added prodigy json file * added "the" in jsonl description Co-authored-by: Matt Robinson <mrobinson@unstructuredai.io>
14 lines
381 B
Python
14 lines
381 B
Python
from typing import List, Dict
|
|
|
|
import json
|
|
|
|
|
|
def save_as_jsonl(data: List[Dict], filename: str) -> None:
|
|
with open(filename, "w+") as output_file:
|
|
output_file.writelines((json.dumps(datum) + "\n" for datum in data))
|
|
|
|
|
|
def read_from_jsonl(filename: str) -> List[Dict]:
|
|
with open(filename, "r") as input_file:
|
|
return [json.loads(line) for line in input_file]
|