All,
I would like to read in data from a data file that contains multiple
headers. Each header line begins with the pound character. I would like to
read the data into a 2-D matrix. Note that I would like to test for the
pound character since I don't know the exact number of header lines in each
case.
Here is an example of the input data file:
-----------------------------------------
# beginning of file
# coherence data
# nx=4 ny=5
# x y y2
0.2 1.23 1.34E-9
NaN -2.454 0.23E12
2.3 -9 1.23E-4
# coherence data 2
# nx=4 ny=5
# x y y3
-0.0 NaN 1.34E-9
NaN -2.454 -0.23E12
122.3 2.34 3.43E-4
3.12 NaN 4.5
#end of file
---------------------------
Then the 4x6 Matrix should look like this:
0.2 1.23 1.34E-9 -0.0 NaN 1.34E-9
NaN -2.454 0.23E12 NaN -2.454 -0.23E12
2.3 -9 1.23E-4 122.3 2.34 3.43E-4
3.12 NaN 4.5
Note that the first three entries in the 4th row are absent. It would be
okay to fill the empty slots with either NaN or leave them blank all
together. Whichever is easier to program.
Any ideas on how to read in such a matrix would be greatly appreciated.
thanks,
Chris