Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .semversioner/next-release/patch-20260705142108838934.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "patch",
"description": "Ignore blank lines when loading JSONL input files."
}
2 changes: 1 addition & 1 deletion packages/graphrag-input/graphrag_input/jsonl.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ async def read_file(self, path: str) -> list[TextDocument]:
- output - list with a TextDocument for each row in the file.
"""
text = await self._storage.get(path, encoding=self._encoding)
rows = [json.loads(line) for line in text.splitlines()]
rows = [json.loads(line) for line in text.splitlines() if line.strip()]
return await self.process_data_columns(rows, path)
21 changes: 21 additions & 0 deletions tests/unit/indexing/input/test_jsonl_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,24 @@ async def test_jsonl_loader_one_file_with_title():
documents = await reader.read_files()
assert len(documents) == 3
assert documents[0].title == "Hello"


async def test_jsonl_loader_ignores_blank_lines(tmp_path):
(tmp_path / "input.jsonl").write_text(
'{"title":"Hello","text":"Hi"}\n\n \n{"title":"Goodbye","text":"Bye"}\n',
encoding="utf-8",
)
config = InputConfig(
type=InputType.JsonLines,
title_column="title",
)
storage = create_storage(
StorageConfig(
base_dir=str(tmp_path),
)
)
reader = create_input_reader(config, storage)
documents = await reader.read_files()
assert len(documents) == 2
assert [doc.title for doc in documents] == ["Hello", "Goodbye"]
assert [doc.text for doc in documents] == ["Hi", "Bye"]