import glob, sys, gzip, random, json dumps = glob.glob("CC-MAIN-*") for dump in dumps: print(dump) buckets = glob.glob(f"{dump}/CC-MAIN-*") for bucket in buckets: bucket = bucket.replace(f"{dump}/", f"{dump}_") bucket = bucket.replace("CC-MAIN-", "") with gzip.open(f"jsonl/{bucket}.jsonl.gz") as fin: count = 0 for line in fin: if random.randint(0, 90) < 3: count += 1 text = json.loads(line)["text"] ss = json.dumps({ "text" : text }, ensure_ascii = False) print(ss) if count == 1000: break