I have a text file data.txt which looks as such:
ADMAS 8.046E+03 8.206E-03 1.532E+04 1.066E-01 6.982E+06-2.820E+00 \n
ADMAS -6.868E-03 2.009E+05 1.454E-02 9.516E+05-1.209E+00 6.058E+06 \n
ADMAS 1.543E+04 9.179E-01 1.459E+06 5.463E+00 3.918E+07-2.904E+01 \n
ADMAS -2.267E-01 9.537E+05 3.902E+00 3.071E+07-1.344E+02 1.073E+08 \n
ADMAS 7.005E+06 2.260E+01 3.978E+07 6.296E+01 7.586E+09-2.125E+03 \n
ADMAS 1.093E+00 6.052E+06-6.178E+00 1.065E+08-1.416E+03 1.941E+09 \n
FAMP 3.824E+03 7.120E-02 1.848E+05 7.317E-01 5.406E+06 4.096E+00 \n
FEPS 9.039E+01 3.571E+02 2.838E+00 3.580E+02 4.098E+01 1.892E+02 \n
(etc. In a recurring pattern). I want to have only the ADMAS values and put them in a 6x6 array. I tried the following:
filename = "data.txt"
string_fnd_1 = "ADMAS"
textfile = open(filename, 'r')
file_lines = textfile.readlines()
textfile.close()
matches_admas = [line for line in file_lines if string_fnd_1 in line]
I get the following:
['ADMAS 8.046E+03 8.206E-03 1.532E+04 1.066E-01 6.982E+06-2.820E+00\n', 'ADMAS -6.868E-03 2.009E+05 1.454E-02 9.516E+05-1.209E+00 6.058E+06\n',....]
Now, I want to get rid of the string "ADMAS", convert the values to float and reshape into a 6x6 array. Does someone know how to do this? Help would be appreciated.