remove_invalid_banks.py
· 426 B · Python
Raw
import csv
import numpy as np
import os
data = []
csv_file = 'NOMAD_Invalid_groups_exported_1.csv'
with open(csv_file, 'r') as file:
csv_reader = csv.reader(file)
next(csv_reader)
for row in csv_reader:
data.append(row)
data = np.array(data)[:, 1]
for i in data:
file_t = f"NOM_Si_640e_bank{i}.dat"
if os.path.exists(file_t):
os.remove(file_t)
print(f"File {file_t} removed.")
1 | import csv |
2 | import numpy as np |
3 | import os |
4 | |
5 | data = [] |
6 | |
7 | csv_file = 'NOMAD_Invalid_groups_exported_1.csv' |
8 | |
9 | with open(csv_file, 'r') as file: |
10 | csv_reader = csv.reader(file) |
11 | next(csv_reader) |
12 | |
13 | for row in csv_reader: |
14 | data.append(row) |
15 | |
16 | data = np.array(data)[:, 1] |
17 | |
18 | for i in data: |
19 | file_t = f"NOM_Si_640e_bank{i}.dat" |
20 | if os.path.exists(file_t): |
21 | os.remove(file_t) |
22 | print(f"File {file_t} removed.") |