Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the loading error of jsonl file #644

Merged
merged 2 commits into from
Sep 10, 2024
Merged
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
14 changes: 13 additions & 1 deletion comps/dataprep/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,16 @@ def load_json(json_path):
return content_list


def load_jsonl(jsonl_path):
"""Load and process jsonl file."""
content_list = []
with open(jsonl_path, "r") as file:
for line in file:
json_obj = json.loads(line)
content_list.append(json_obj)
return content_list


def load_yaml(yaml_path):
"""Load and process yaml file."""
with open(yaml_path, "r") as file:
Expand Down Expand Up @@ -351,8 +361,10 @@ def document_loader(doc_path):
return load_md(doc_path)
elif doc_path.endswith(".xml"):
return load_xml(doc_path)
elif doc_path.endswith(".json") or doc_path.endswith(".jsonl"):
elif doc_path.endswith(".json"):
return load_json(doc_path)
elif doc_path.endswith(".jsonl"):
return load_jsonl(doc_path)
elif doc_path.endswith(".yaml"):
return load_yaml(doc_path)
elif doc_path.endswith(".xlsx") or doc_path.endswith(".xls"):
Expand Down
Loading