File size: 612 Bytes
149cce2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import pathlib

import orjson

with open("compiled.jsonl","wb") as f:
    for file in pathlib.Path("data").iterdir():
        if file.is_file():
            pushback = ""
            for line in file.read_text(encoding="utf-8").split("\n"):
                if line == "":
                    pushback += "\n"
                    continue
                if line == line.upper():
                    continue
                else:
                    pushback += line + "\n"
            pushback = pushback.strip()
            # print(pushback.strip())
            f.write(orjson.dumps({"text":pushback}) + b"\n")