help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: textread ; ignoring header lines


From: Paul Kienzle
Subject: Re: textread ; ignoring header lines
Date: Thu, 8 Jan 2004 23:12:20 -0500

If your file contains columns of numbers, you don't want to use textread.
It will be slow.  You may be able to use load directly since load
understands some comment styles.  You may also be able to use
dlmread('file',' ',skip,1), but I haven't tried it.

Otherwise you will have to do something like:

        * UNTESTED *
        fid = fopen(file);
        for i=1:skip, fgets(fid);
        data = fscanf(fid,"%f",Inf);
        data = reshape(data,n,length(data)/n)';

If you really do need textread (because you have mixed
strings and numbers) then extended it to understand

        textread(...,'headerlines',n)

Please post the changes so they can be added back to
octave-forge.

Paul Kienzle
address@hidden

On Jan 8, 2004, at 9:49 AM, Y U Sasidhar wrote:

many times the data files have a few header lines beginning with #, @, % etc
followed by columns of data like:

# comment1
@ another comment

1    2    3
4    5    6

etc

how do I tell textread to ignore those header lines ?



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]