Download src/01_batch_data.py from Desp-ML/Bioactivity_report_QM9: direct link, hf CLI and curl.
- Browser
- Download file 520 Bytes
-
https://huggingface.co/datasets/Desp-ML/Bioactivity_report_QM9/resolve/main/src/01_batch_data.py
- Command line
-
hf download hf://datasets/Desp-ML/Bioactivity_report_QM9/src/01_batch_data.py
-
curl -L -o 01_batch_data.py https://huggingface.co/datasets/Desp-ML/Bioactivity_report_QM9/resolve/main/src/01_batch_data.py
520 Bytes
| 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)) |