MCPcopy Create free account
hub / github.com/EntilZha/PyFunctional / to_jsonl

Method to_jsonl

functional/pipeline.py:1528–1540  ·  view source on GitHub ↗

Saves the sequence to a jsonl file. Each element is mapped using json.dumps then written with a newline separating each element. :param path: path to write file :param mode: mode to write in, defaults to 'w' to overwrite contents :param compression: compress

(self, path, mode="wb", compression=None)

Source from the content-addressed store, hash-verified

1526 output.write(str(self))
1527
1528 def to_jsonl(self, path, mode="wb", compression=None):
1529 """
1530 Saves the sequence to a jsonl file. Each element is mapped using json.dumps then written
1531 with a newline separating each element.
1532
1533 :param path: path to write file
1534 :param mode: mode to write in, defaults to 'w' to overwrite contents
1535 :param compression: compression format
1536 """
1537 with universal_write_open(path, mode=mode, compression=compression) as output:
1538 output.write(
1539 (self.map(json.dumps).make_string("\n") + "\n").encode("utf-8")
1540 )
1541
1542 def to_json(self, path, root_array=True, mode=WRITE_MODE, compression=None):
1543 """

Callers 2

test_to_jsonlMethod · 0.80

Calls 3

mapMethod · 0.95
universal_write_openFunction · 0.90
make_stringMethod · 0.80

Tested by 2

test_to_jsonlMethod · 0.64