I have the following Code
import numpy as np
from readers import readerXYZ
import glob
folder=r'N:\FolderXYZ/*'
D_list=[]
ctr=0
for name in glob.glob (folder):
Zdata = readerXYZ(name, output_matrix=True)
#I Need this counter of the NaNs for future computations
ctr=ctr+np.count_nonzero(np.isnan(Zdata))
a=list(Zdata.shape)
D_list.append(a)
The program reads from different files stored in the Folder called "FolderXYZ", this is done with an external program called readerXYZ, what I want to store in the lis D_list is the dimensions of each Zdata Matrix, and at the same time count how many NaNs are in total. This code works fine but takes so Long, how can I improve it? thank you
1 Answer 1
If time is your concern. You can consider processing the list in parallel. Here is a reference for multiprocessing Python how to parallelize loops
answered Apr 23, 2019 at 8:54
Saad Anjum
1031 gold badge1 silver badge8 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py
readerXYZfunction...