English-USAS-Mosaico / example_loading_script.py
apmoore1's picture
How to load the dataset
fab722b verified
raw
history blame contribute delete
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