1

I have a list of file name fragments, and I want to return a list of all the file names under a certain directory.

I wrote this code to tackle this problem, but it turns out that is a rather slow solution.

train_file_list = []
for p in patient_list[:n_train]:
    file = glob(os.path.join("D:\preprocess_data\Positive", p + "*.npz"))
    train_file_list.append(file)

Hopefully, I can rely on your talent to come up with a more efficient way to do this. Thanks!!!

yujuezhao
  • 1,015
  • 3
  • 11
  • 21

0 Answers0