help-octave
[Top][All Lists]
Advanced

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

Re: [Q] Skipping input


From: John C. Campbell
Subject: Re: [Q] Skipping input
Date: Thu, 25 Aug 1994 09:35:53 CDT

address@hidden (Krzysztof Gozdziewski) writes...

| I have following problem: I want to read data from text file. The file
| is organized in such a wy, that in its first two lines there is some
| description, next  are some lines with numbers, next two lines
| of comments, numbers, comments, etc. 

This is a common question and the answer (aside from using sed or awk
outside of Octave) is to use the C-style IO functions.  These
functions are completely flexible yet tedious to use.  If you are
processing lots of data files with the same format then the overhead
(your time spend coding) will be much smaller than if you have to
parse each data file differently.  I wrote some code that would use
'fgets' to get a string from a file, then I used 'sscanf' to scan that
string for strings and numbers.

The use of these functions (sscanf, fscanf, scanf, gets, printf,
sprintf, fprintf, getc, fseek, ftell, frewind, etc) is well documented
in Octave but you could also use your favorite C book to get the
flavor of these functions.

John

--------
John C. Campbell                    :  
address@hidden                  :  
University of Texas-Austin          :  
Dept. of Chemical Engineering       :  




reply via email to

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