help-octave
[Top][All Lists]
Advanced

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

Importing fixed field-width ascii data files with fscanf


From: E. Joshua Rigler
Subject: Importing fixed field-width ascii data files with fscanf
Date: Fri, 17 Aug 2001 16:06:19 -0600

I need to read in a fixed format ascii file.  Apparently the scanf
functions ignore any kind of field width and precision information. 
Actually, they don't ignore it, but return an error if you try to
specify them!!!

Even if it's admittedly outdated, fixed-width ascii data files are very,
very common.  What's more, is that most such files make no consideration
of field delimiters like white space.  Is there any way to read these in
in Octave?

In case it's not obvious, consider the following sample ascii data
file...

 1 99.9
 2 99.9
 3-99.9
 4 99.9

What _should_ work (IMHO) as a template for scanf is something like...

 fid = fopen("foo.txt","r");
 val = fscanf(fid,"%i3%5.1");

...but it doesn't, and I can't find a way to read in a data file like
this sample without actually altering the file by hand.  I've looked
through the list archives for anything pertaining to fscanf, and it
seems nobody has had this problem before.  I find this surprising, so I
wonder if I'm just doing something really stupid.

-EJR



-------------------------------------------------------------
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]