KaraKaraWitch's picture
Upload scripts/combine.py with huggingface_hub
643c37e verified
raw
history blame contribute delete
711 Bytes
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)