Datasets:
Download examples/read_dataset.py from chembricks/chemistry-knowledge: direct link, hf CLI and curl.
- Browser
- Download file 738 Bytes
-
https://huggingface.co/datasets/chembricks/chemistry-knowledge/resolve/main/examples/read_dataset.py
- Command line
-
hf download hf://datasets/chembricks/chemistry-knowledge/examples/read_dataset.py
-
curl -L -o read_dataset.py https://huggingface.co/datasets/chembricks/chemistry-knowledge/resolve/main/examples/read_dataset.py
738 Bytes
| """Read the release with Python's standard library.""" | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| root = Path(__file__).resolve().parents[1] | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--record-id") | |
| args = parser.parse_args() | |
| with (root / "data/records.jsonl").open() as stream: | |
| for line in stream: | |
| record = json.loads(line) | |
| if args.record_id is None or record["record_id"] == args.record_id: | |
| print(record["record_id"]) | |
| print(record["beginner_question"]) | |
| print(record["answer"]) | |
| print("Limitations:", record["limitations"]) | |
| break | |
| else: | |
| raise SystemExit("Record not found in the complete-record subset.") | |