I have the following loop, where cfile has been defined as 'C_' previously.
for i in range(15,25): infile = cfile + str(i+1) + '.txt' C + str(i+1) = np.loadtxt (infile,delimiter=',')
I have many files in the working directory named C_1, C_2, etc. I'd like to import these files into Python and name them as C_1, C_2, etc, but I'd only like to do so for that certain range. I am not understanding why the str(i+1) will not work.
https://stackoverflow.com/questions/65784180/reading-in-multiple-files-in-python-and-renaming-them-using-string-stri1-no January 19, 2021 at 09:06AM
没有评论:
发表评论