Jul-02-2020, 12:56 AM
Instead of storing the data in regular variables (like matrix1), store them in a list or a dictionary.
You can create the filenames in a loop by range(), but it might be better to use os.listdir() or glob.glob() to get a list of all the files that exist that match what you want.
You can create the filenames in a loop by range(), but it might be better to use os.listdir() or glob.glob() to get a list of all the files that exist that match what you want.
matrix_data = {} for file_index in range(1,10): filename = f"File_{file_index}.txt" file = np.loadtxt(filename, delimiter=',') matrix_data[filename] = file[:,:]# can refer to matrix_data["File_1.txt"] for the data...