I need to import variables from a txt file. This file has 3 main parts.
A) Initial headlines, containing general information
B) Headlines-Variables, in every column
C) Numerical data in every column
As below:
Headlines - Headlines - Headlines - Headlines
Headlines - Headlines - Headlines - Headlines
# A | B C | D |
# ----------+----------------------------+---------------|
# 1 | 0.0000E+00 + 0.0000E+00 | 0.0000 |
# 2/3 | 0.0000E+00 +/- 0.0000E+00 | 0.0000 |
# 4/5 | 0.0000E+00 +/- 0.0000E+00 | 0.0000 |
# 6 | 0.0000E+00 + 0.0000E+00 | 0.0000 |
The problem is that the initial headlines are changing every time, so we cant declare a specific number of rows initially to avoid.
As you can see we have 2 different row formats. So we cant write a specific format for every line and the number of the numerical data in every column are changing also.
I cant do that (Data=textscan(fid,'%s %f %s %f %s %f %s %f', 'headlines', 4)
I have only two different types of row format
How can I import only the numerical data in every row.
Please HELP
My favourite method is to read in the whole file with this magical command:
buf=textread(filename,'%s','delimiter','\n');
and then to parse it. In this case it seems easy to detect the data lines by looking for an initial #.