I need help with stopping a code from reading files from a folder. I can get my code to read all files starting from the one I assign, but I don't know how to stop the reading of the files as there are files that I don't need. I need to create an array so the indexes should be the same size, i.e. I should be able to somehow dismiss part of the files in the folder in order to have the array working. So I need help on how to break the reading of the files and start it again (so read f.ex. files number 3-5 and then 8-9 and skip 6-7).
The code in itself is this:
The code in itself is this:
scan_number = np.array([1]) file_start = 20 file_folder = '\\\\location of folder in my computer\\mca_{:05}' sample_data = fn.Sum_import_data(file_start, scan_number, n_pts, n_chnl, file_folder)With the operating function being this
def Sum_import_data(file_start, scan_number, n_pts, n_chnl, file_folder): output = np.empty([n_chnl, n_pts]) mcadata = np.empty([n_chnl, np.size(scan_number)]) for i in np.arange(0, n_pts): current_mca = file_start + (scan_number - scan_number[0])*n_pts + i for j in np.arange(0, np.size(current_mca)): mcadata[:,j] = np.loadtxt(file_folder.format(current_mca[j])) output[:,i] = np.sum(mcadata, axis=1) return(output)So I would have to be able to read the files from file 20 to file 60 and 80 to 220 in the folder which contains files from 0 to 281, but I don't know how to stop the reading of these files at a specific file and start again. I don't know if it would be possible to break the reading of the file in the file_start command line or if I should modify the function itself as it now adds (current_mca line) the next files automatically without a stop. Any help is much appreciated!