Extract data from ASCII text file from specific lines and columns

1 次查看(过去 30 天)
Hi Guys,
I have a compilation of reports in an ASCII file (see the file here: http://pastebin.com/wmmB92ZC ) I want to export them to MATLAB and I know the specific location of the data in column and line.
For example, the data for parameter N1 is located at line 37&38 at column 4. The next data for N1 comes after every 53 lines, which are 90&91, 143&,144 and so on.
I did try with text scan, but there is no option to specifically tell the exact location of the data in columns and lines.
Any help would be appreciated.
Thanks.
Regards, Wan

回答(1 个)

Walter Roberson
Walter Roberson 2012-4-18
There is an undocumented textscan() option to specify column location. Unfortunately it only works with purely numeric data.
Anyhow, use the HeaderLines parameter to indicate how many lines to skip. Use a '%*s%*s%*s%d' format to skip the fist 3 columns and read the 4th as a number.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by