File size: 386 Bytes
fab722b
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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