MCPcopy
hub / github.com/pathwaycom/pathway / read_jsonlines

Function read_jsonlines

python/pathway/tests/utils.py:807–821  ·  view source on GitHub ↗

Return parsed rows from a JSON-Lines file, or `[]` if the file does not exist yet. Blank lines are skipped. The missing-file branch matters for streaming-pipeline tests that may poll for output before the first row lands on disk.

(path: str | pathlib.Path)

Source from the content-addressed store, hash-verified

805
806
807def read_jsonlines(path: str | pathlib.Path) -> list[dict]:
808 """Return parsed rows from a JSON-Lines file, or `[]` if the file does not
809 exist yet. Blank lines are skipped. The missing-file branch matters for
810 streaming-pipeline tests that may poll for output before the first row
811 lands on disk."""
812 path = pathlib.Path(path)
813 if not path.exists():
814 return []
815 rows: list[dict] = []
816 with open(path) as f:
817 for line in f:
818 line = line.strip()
819 if line:
820 rows.append(json.loads(line))
821 return rows
822
823
824def get_aws_s3_settings():

Calls 2

stripMethod · 0.80
loadsMethod · 0.45