Datasets:
Download example_loading_script.py from ucrelnlp/English-USAS-Mosaico: direct link, hf CLI and curl.
- Browser
- Download file 386 Bytes
-
https://huggingface.co/datasets/ucrelnlp/English-USAS-Mosaico/resolve/main/example_loading_script.py
- Command line
-
hf download hf://datasets/ucrelnlp/English-USAS-Mosaico/example_loading_script.py
-
curl -L -o example_loading_script.py https://huggingface.co/datasets/ucrelnlp/English-USAS-Mosaico/resolve/main/example_loading_script.py
386 Bytes
| from pathlib import Path | |
| import gzip | |
| import json | |
| # Loops over each JSONL file | |
| for data_file in Path("data").glob("*.jsonl.gz"): | |
| print(data_file) | |
| # Opens the file | |
| with gzip.open(str(data_file), "rt", encoding="utf-8") as f: | |
| # Reads the first line of the file and prints it and then breaks | |
| for line in f: | |
| print(json.loads(line)) | |
| break | |