[Top][All Lists]

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

reading delimited files

From: John W. Eaton
Subject: reading delimited files
Date: Thu, 29 Mar 2001 12:36:01 -0600

On 29-Mar-2001, John Day <address@hidden> wrote:

| I'm trying read delimited files in Octave and looking for something like 
| MATLAB's dlmread(), which is slow but versatile.
| On a two-column pipe-delimited file I tried
|     mat = fscanf(fid, "%f|%f\n", [Inf,2])
| hoping to get a 2-column file. Instead I got all the data in one-column, 
| interleaved so that reshape() can't fix it. (A bug?)

It seems that Octave should give you an error for this, since it
really only allows N in the [M, N] size specification to be Inf.  It
is handling your [Inf, 2] the same as just Inf.

| I am using ver 2.1.25. Any suggestions how to read delimited files of 
| various sizes with various delimiters?

You can use

  mat = fscanf(fid, "%f|%f\n", [2, Inf])'

(read the rows of the data file in as columns of a 2xN matrix and then
transpose the result).


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]