help-octave
[Top][All Lists]
Advanced

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

RE: read only a certain number of lines using textread


From: Tim Rueth
Subject: RE: read only a certain number of lines using textread
Date: Thu, 19 Aug 2010 11:30:18 -0700

> -----Original Message-----
> From: Jaroslav Hajek [mailto:address@hidden 
> Sent: Thursday, August 19, 2010 1:05 AM
> To: address@hidden
> Cc: address@hidden
> Subject: Re: read only a certain number of lines using textread
> 
> On Thu, Aug 19, 2010 at 2:28 AM, Tim Rueth <address@hidden> wrote:
> > I wish to read only a certain number of lines of a text file using 
> > textread().  For example, I have an input file:
> >
> > 1    2
> > 3    4
> > 5    6
> > 7    8
> >
> > Let's say I want to read the first n rows into var1 and 
> var2.  I would say:
> >
> > [var1 var2] = textread(infile, "%f %f", n);
> >
> > This doesn't seem to work...textread will read all of the 
> lines into 
> > var1 and var2, as if "n" didn't exist.  Is this a bug, or 
> am I doing 
> > something wrong?  (I'm running version 3.2.3 on Vista.)
> >
> > Also, let's say I have a text string, "foo" at the end of 
> the file, like so:
> >
> > 1    2
> > 3    4
> > 5    6
> > 7    8
> > foo
> >
> > If I use textread() to read the first 4 rows into var1 and var2, is 
> > there a way to then read "foo" into a string variable?
> >
> > Thanks,
> >
> > --Tim
> 
> textread is not part of Octave 3.2.x. Where did you get the 
> function from? The 3.3+ version has textread, but the feature 
> of limiting the number of lines is missing. If you want it 
> (or help with doing it), please open a feature request at the 
> bug tracker https://savannah.gnu.org/bugs/?group=octave
> 
> hth
> --
> RNDr. Jaroslav Hajek, PhD
> computing expert & GNU Octave developer
> Aeronautical Research and Test Institute (VZLU) Prague, Czech Republic
> url: www.highegg.matfyz.cz

Andy:  Thanks for the fopen / fgetl suggestion.

Jaroslav:  My textread.oct in Octave 3.2.3 comes from the io-1.0.9 package,
which got installed when I installed Octave 3.2.3_gcc-4.4.0 with all the
packages.

--Tim




reply via email to

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