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.")