Download augmentoolkit/utils/load_dataset.py from Leon4gr45/agent-0: direct link, hf CLI and curl.
- Browser
- Download file 676 Bytes
-
https://huggingface.co/spaces/Leon4gr45/agent-0/resolve/main/augmentoolkit/utils/load_dataset.py
- Command line
-
hf download hf://spaces/Leon4gr45/agent-0/augmentoolkit/utils/load_dataset.py
-
curl -L -o load_dataset.py https://huggingface.co/spaces/Leon4gr45/agent-0/resolve/main/augmentoolkit/utils/load_dataset.py
676 Bytes
| import json | |
| import pyarrow.parquet as pq | |
| def load_dataset(file_path): | |
| if file_path.endswith(".parquet"): | |
| table = pq.read_table(file_path) | |
| dataset = table.to_pandas() | |
| elif file_path.endswith(".json"): | |
| with open(file_path, "r", encoding="utf-8") as file: | |
| dataset = json.load(file) | |
| elif file_path.endswith(".jsonl"): | |
| dataset = [] | |
| with open(file_path, "r", encoding="utf-8") as file: | |
| for line in file: | |
| dataset.append(json.loads(line)) | |
| else: | |
| raise ValueError( | |
| "Unsupported file format. Please provide a parquet, json, or jsonl file." | |
| ) | |
| return dataset | |