File size: 520 Bytes
2168597 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import os
import math
input_dir = "input_data"
output_dir = "batches"
batch_size = 1000
os.makedirs(output_dir, exist_ok=True)
all_files = sorted([
os.path.join(input_dir, f)
for f in os.listdir(input_dir)
if f.endswith(".xyz")
])
n_batches = math.ceil(len(all_files) / batch_size)
for i in range(n_batches):
batch_files = all_files[i*batch_size : (i+1)*batch_size]
with open(f"{output_dir}/batch_{i:03d}.txt", "w") as f:
f.write("\n".join(batch_files)) |