Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

JSONReader: Encoding fixes UnicodeDecodeError #665

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions llama_hub/file/json/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,22 @@ def load_data(
file: Path,
is_jsonl: Optional[bool] = False,
extra_info: Optional[Dict] = None,
encoding: Optional[str] = "utf-8"
) -> List[Document]:
"""Load data from the input file.

Args:
file (Path): Path to the input file.
is_jsonl (Optional[bool]): If True, indicates that the file is in JSONL format. Defaults to False.
extra_info (Optional[Dict]): Additional information. Default is None.
encoding: (Optional[str]): Encoding of file. Default is UTF-8

Returns:
List[Document]: List of documents.
List[Document]: List of documents.
"""
if not isinstance(file, Path):
file = Path(file)
with open(file, "r") as f:
with open(file, "r", encoding=encoding) as f:
data = []
if is_jsonl:
for line in f:
Expand Down
Loading