import os

max_rows = 10000  # max rows per split file

for letter in ['A', 'B', 'C']:
    index = 0
    row_count = 0
    input_file = os.path.join("proveit-data", f"Enterprise_{letter}.json")
    
    if not os.path.isfile(input_file):
        raise FileNotFoundError(f"{input_file} not found")
    
    output_file = input_file.replace(".json", f".{index+1}.json")
    
    with open(input_file, 'r') as rf, open(output_file, 'w') as wf:
        for line in rf:
            if line.strip():  # skip empty lines
                wf.write(line)
                row_count += 1
                if row_count >= max_rows:
                    index += 1
                    row_count = 0
                    wf.close()
                    output_file = input_file.replace(".json", f".{index+1}.json")
                    wf = open(output_file, 'w')
                    # exit(1) 
