I have some text files in a folder and I need to read all of them into a matrix, but when I use the following code:
with open('E:/UGC/Animationpsnr_bitrate_0.txt','r') as file:
psnr_bitrate = file.readlines()
It produces an str list but I need to save them as float variables. In the following I put a sample of text file content:
33.773083 36.171250 38.032833 39.589417 40.937167 42.214250
45.867417 49.271917 51.478500 53.247500 54.981250 56.507333
48.421417 51.848833 54.390500 56.687750 58.457333 60.029583
48.790583 52.691333 55.534750 57.793250 59.953167 61.538500
Suppose I have 20 text files in a folder with contents like above. finally, I need to read all files and save them in a matrix that has 6 columns and the rows are all the text file values. could you please tell me how can I do this?