KaraKaraWitch
commited on
Commit
•
643c37e
1
Parent(s):
0433535
Upload scripts/combine.py with huggingface_hub
Browse files- scripts/combine.py +19 -0
scripts/combine.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
# Folder containing the part files
|
4 |
+
parts_folder = './output'
|
5 |
+
# Name of the final, large JSONL file
|
6 |
+
final_file_name = './french_books.jsonl'
|
7 |
+
|
8 |
+
part_files = sorted([f for f in os.listdir(parts_folder) if f.startswith('output_part_') and f.endswith('.jsonl')])
|
9 |
+
|
10 |
+
|
11 |
+
with open(final_file_name, 'w', encoding='utf-8') as final_file:
|
12 |
+
for part_file in part_files:
|
13 |
+
part_path = os.path.join(parts_folder, part_file)
|
14 |
+
with open(part_path, 'r', encoding='utf-8') as file:
|
15 |
+
for line in file:
|
16 |
+
# Write each line (JSON object) to the final file
|
17 |
+
final_file.write(line)
|
18 |
+
|
19 |
+
print("All part files have been concatenated into", final_file_name)
|