File size: 711 Bytes
643c37e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os

# Folder containing the part files
parts_folder = './output'
# Name of the final, large JSONL file
final_file_name = './french_books.jsonl'

part_files = sorted([f for f in os.listdir(parts_folder) if f.startswith('output_part_') and f.endswith('.jsonl')])


with open(final_file_name, 'w', encoding='utf-8') as final_file:
    for part_file in part_files:
        part_path = os.path.join(parts_folder, part_file)
        with open(part_path, 'r', encoding='utf-8') as file:
            for line in file:
                # Write each line (JSON object) to the final file
                final_file.write(line)

print("All part files have been concatenated into", final_file_name)