Reading ASCII data files into octave

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Reading ASCII data files into octave

Marco Bravi-2
Dear Octave users,

I am a frequent matlab user, who is accustomed to being able to read ASCII
data files simply containing one matrix of data, without having to first
specify in the file itself the size of the data about to read.

Is there any way to have Octave do the same, without first adding those
four lines before each matrix contained in the file???

Thanks a lot in advance,

                                Marco Bravi

--
Marco Bravi [hidden email]
Dip. Ing. Chimica tel. +39-6-44585587 / 612
v. Eudossiana, 18 fax  +39-6-4827453
I-00184 Roma (Italy)


Reply | Threaded
Open this post in threaded view
|

Re: Reading ASCII data files into octave

Dirk Eddelbuettel-2

  Marco>  Dear Octave users, I am a frequent matlab user, who is accustomed
  Marco> to being able to read ASCII data files simply containing one matrix
  Marco> of data, without having to first specify in the file itself the size
  Marco> of the data about to read.
  Marco>
  Marco> Is there any way to have Octave do the same, without first adding
  Marco> those four lines before each matrix contained in the file???

You want to use the aload.m and asave.m functions. There are actually two
sets of them. The first (which is older and simpler) is somewhere on

        ftp://ftp.tsc.uvigo.es/pub/octave/

and the second is, with a lot of other stuff I can recommend, in

        ftp://ftp.ci.tuwien.ac.at/pub/octave/octave-ci.tar.gz

Regards, Dirk

--
 [hidden email]   http://rosebud.sps.queensu.ca/~edd   PGP KeyID 1024/6D7F08DD



Reply | Threaded
Open this post in threaded view
|

Re: Reading ASCII data files into octave

John W. Eaton-6
On 16-Oct-1997, Dirk Eddelbuettel <[hidden email]> wrote:

|   Marco>  Dear Octave users, I am a frequent matlab user, who is accustomed
|   Marco> to being able to read ASCII data files simply containing one matrix
|   Marco> of data, without having to first specify in the file itself the size
|   Marco> of the data about to read.
|   Marco>
|   Marco> Is there any way to have Octave do the same, without first adding
|   Marco> those four lines before each matrix contained in the file???
|
| You want to use the aload.m and asave.m functions.

I don't think you really need those now:

  $ cat foo.dat
  1 2.3 4.5
  6 7.8 9.0
  $ octave
  Octave, version 2.0.9 (i686-pc-linux-gnu).
  Copyright (C) 1996, 1997 John W. Eaton.
  This is free software with ABSOLUTELY NO WARRANTY.
  For details, type `warranty'.

  octave:1> load foo.dat
  octave:2> foo
  foo =

    1.0000  2.3000  4.5000
    6.0000  7.8000  9.0000

This feature was added sometime before 2.0 was released.

jwe


Reply | Threaded
Open this post in threaded view
|

Re: Reading ASCII data files into octave

Michael Martins-2
In reply to this post by Dirk Eddelbuettel-2
Hello

>   Marco> Is there any way to have Octave do the same, without first adding
>   Marco> those four lines before each matrix contained in the file???
>
> You want to use the aload.m and asave.m functions. There are actually two
> sets of them. The first (which is older and simpler) is somewhere on

The method "load var.dat" has one disadvantage. Is is not possible to
put some remarks starting with "#" into the file. Is it possible to change
this in octave, to make it possible to load files like:

#comment1
#comment2
#...
1 2 3
2 3 4
3 4 5
#comment ...

This would be nice, because nearly all of my data files looks like this.

Ciao
        Michael

--
|\  /|  Dr. Michael Martins, Freie Universitaet Berlin
| \/ |  Institut fuer Experimentalphysik
| |\/|  Arnimallee 14,            Tel.: +49-30-838 2688
| |  |  D-14195 Berlin, Germany     Email: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Reading ASCII data files into octave

John W. Eaton-6
On 17-Oct-1997, Michael Martins <[hidden email]> wrote:

| The method "load var.dat" has one disadvantage. Is is not possible to
| put some remarks starting with "#" into the file. Is it possible to change
| this in octave, to make it possible to load files like:
|
| #comment1
| #comment2
| #...
| 1 2 3
| 2 3 4
| 3 4 5
| #comment ...
|
| This would be nice, because nearly all of my data files looks like this.

I've added a note about this to the PROJECTS file.  That means that I
agree that it would be nice to have this feature, but I don't have any
immediate plans to implement it myself.  If someone else were to
provide the necessary code, however, I could probably be persuaded to
install it.

Thanks,

jwe