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