From: Yugabalan K on
Hi all,

I have used textscan previously, by manually specifying the point I would like the text file to be read. For example in the following text, if I wanted to read from the 3rd row, the 'HeaderLines' parameter could set to 2 (assuming the first row starts in line 1).

A002 7200 7061 7062 7201 PL1
A003 7201 7062 7063 7202 PL1
A004 7202 7063 7064 7203 PL1
A005 7203 7064 7065 7204 PL1
A006 7204 7065 7066 7205 PL1
A007 7200 7224 7051 7061 PL1
A008 7224 7223 7039 7051 PL1
A009 7223 7221 7027 7039 PL1
A010 7221 7206 7015 7027 PL1

My problem is, in almost all the text files I have (hundreds of them), the information of row 3, i.e. A004 7202 7063 7064 7203 PL1, varies in each text files location (inconsistent line number in every text files).

The ideal way in my mind is for textscan to search for string "A004" and returns the line number, so that I could manupulate it further as 'HeaderLines' parameter. Is this possible with textscan?

Note that what I've presented above is just an example. The actual text file has over half a million lines, and the text orientations are mixed up.

I'm open for any other suggestion that I could give a try. Thanking in advance.

-yuga
From: Branko on
"Yugabalan K" <kyugabalan(a)hotmail.com> wrote in message <huqded$keu$1(a)fred.mathworks.com>...
> Hi all,
>
> I have used textscan previously, by manually specifying the point I would like the text file to be read. For example in the following text, if I wanted to read from the 3rd row, the 'HeaderLines' parameter could set to 2 (assuming the first row starts in line 1).
>
> A002 7200 7061 7062 7201 PL1
> A003 7201 7062 7063 7202 PL1
> A004 7202 7063 7064 7203 PL1
> A005 7203 7064 7065 7204 PL1
> A006 7204 7065 7066 7205 PL1
> A007 7200 7224 7051 7061 PL1
> A008 7224 7223 7039 7051 PL1
> A009 7223 7221 7027 7039 PL1
> A010 7221 7206 7015 7027 PL1
>
> My problem is, in almost all the text files I have (hundreds of them), the information of row 3, i.e. A004 7202 7063 7064 7203 PL1, varies in each text files location (inconsistent line number in every text files).
>
> The ideal way in my mind is for textscan to search for string "A004" and returns the line number, so that I could manupulate it further as 'HeaderLines' parameter. Is this possible with textscan?
>
> Note that what I've presented above is just an example. The actual text file has over half a million lines, and the text orientations are mixed up.
>
> I'm open for any other suggestion that I could give a try. Thanking in advance.
>
> -yuga

doc regexp

Branko