I am reading in a text file into python. The text file contains a (large) number of variables with the variable name given as a string on the left and the value on the right, separated by an equals sign (=). For example
Proc_Method = 2
Obs_Method = 4
So long as the value of the variable is given in a single line I am able to read out the value of the variable correctly with:
namevalue = data.split('=')
name = namevalue[0].strip()
value = namevalue[1].strip()
However, if the variable is spread over multiple lines (i.e. an array). This code only assigns the FIRST row of the array to the variable before moving on to the next variable. So if I had a variable of the following form:
Corr_Mat = 10 0 0
20 10 0
0 20 10
the above code would state that value equaled 10 0 0 and then move on to the next variable. Is there a way I can define value so that it takes ALL the lines starting with the equal sign, and finishes at the line before the next equality in the text file?
=if not consider the line as the value of the previous key?