[Top][All Lists]

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

Re: load ASCII file

From: Mike Miller
Subject: Re: load ASCII file
Date: Wed, 10 Apr 2002 09:44:18 -0500 (CDT)

On Wed, 10 Apr 2002, Paul Söderlind wrote:

> I wanted to load an ACII file with an array of numbers, using Octave
> 2.1.35 on cygwin (windows), but I often got an error message about
> "inconsistent number of columns..."
> This seems to happen when there are spaces (ASCII code 032) after the
> last number on at least one line - and when the file is saved as a PC
> file (carriage return/line feed at the end of each line, ASCII 013 and
> 010). It does not happen when the same file is saved as a UNIX file
> instead (line feed at the end of each line, ASCII 010).
> I quick fix is to use the fscanf(fid,'%f') command instead: it seems to
> work in all these cases.

Other ways to deal with that problem outside of Octave:

dos2unix command, if available will do it (sometimes dos2unix -ascii)

or use tr -d to strip the ^Ms (ASCII 13 decimal but 15 in octal):

tr -d '\015' < datafile > TEMPFILE ; \mv -f TEMPFILE datafile

I haven't used cygwin in a while so I don't remember which of these will
work, but probably tr is available on cygwin.


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

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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