load problems

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

load problems

Ben Sapp
I have a lot of ascii files with names like 10n14.wav, 12s20.wav,
15s6.wav that have data I want to look at in Octave.   The file has one
value per line.  The problem is the name of the file.  Octave loads the
variable into memory as 10n14 and the like.  Then if I try to operate on
the data like so,  

wave_forms = reshape( 10n14 ,500,max(size(10n14))/500);
or
temp = 10n14;

I get a parse error.   I tried to get octave to name the variables
something different with,

load "9n6b.wav" temp

but, it reports the following message:
warning: load: loaded ASCII file `9n6b.wav' -- ignoring extra args

I thought from the documentation that this would read "9n6b.wav into
temp.  Renaming the files is unacceptable.   Is there any easy
workaround?  

I am using Octave 2.1.30 on IRIX 6.5  

Thanks.  

--
Ben Sapp                         Los Alamos National Laboratory
email: <mailto:[hidden email]>   Phone: (505)667-3277
Fax:   (505)665-7920             URL:   http://www.neutrino.lanl.gov/
--



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

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------


Reply | Threaded
Open this post in threaded view
|

Re: load problems

Francis Courtois
why not do this:

system(['cp -f ' Name1 ' tmp.wav']);
load -ascii tmp.wav ;
EXTRACT YOUR DATA HERE e.g. :
eval(['x' Name1 '=tmp;']); clear tmp;
system('rm tmp.wav'); % Not necessary

?


On  2 Aug, Ben Sapp wrote:

> I have a lot of ascii files with names like 10n14.wav, 12s20.wav,
> 15s6.wav that have data I want to look at in Octave.   The file has one
> value per line.  The problem is the name of the file.  Octave loads the
> variable into memory as 10n14 and the like.  Then if I try to operate on
> the data like so,  
>
> wave_forms = reshape( 10n14 ,500,max(size(10n14))/500);
> or
> temp = 10n14;
>
> I get a parse error.   I tried to get octave to name the variables
> something different with,
>
> load "9n6b.wav" temp
>
> but, it reports the following message:
> warning: load: loaded ASCII file `9n6b.wav' -- ignoring extra args
>
> I thought from the documentation that this would read "9n6b.wav into
> temp.  Renaming the files is unacceptable.   Is there any easy
> workaround?  
>
> I am using Octave 2.1.30 on IRIX 6.5  
>
> Thanks.  
>

--

Francis

 =========================================================================
 Dr. Francis COURTOIS               I  ENSIA - INRA
                                    I  1, avenue des Olympiades
 Food Process Control Lab.          I  91744 MASSY Cedex
 Food Engineering Department        I  FRANCE
 -----------------------------------I  Tel : (+33) (0) 1 69 93 51 29
 mailto:[hidden email]      I  Fax : (+33) (0) 1 69 93 51 85
 <a href="http://ensia.inra.fr/Šþcourtois">http://ensia.inra.fr/Šþcourtois     I  Cell: (+33) (0) 6 84 13 73 92
==========================================================================



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

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------


Reply | Threaded
Open this post in threaded view
|

Re: load problems

Ben Sapp
[hidden email] wrote:

>
> why not do this:
>
> system(['cp -f ' Name1 ' tmp.wav']);
> load -ascii tmp.wav ;
> EXTRACT YOUR DATA HERE e.g. :
> eval(['x' Name1 '=tmp;']); clear tmp;
> system('rm tmp.wav'); % Not necessary
>
> ?

This is a good idea.  I knew someone would think of a better solution
than I came up with.(a C++ dynamically linked file)  However, I think I
will use ln rather than cp, because the files can be somewhat large.  

Thanks.  

--
Ben Sapp                         Los Alamos National Laboratory
email: <mailto:[hidden email]>   Phone: (505)667-3277
Fax:   (505)665-7920             URL:   http://www.neutrino.lanl.gov/
--



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

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------


Reply | Threaded
Open this post in threaded view
|

Re: load problems

John W. Eaton-6
On  2-Aug-2000, Ben Sapp <[hidden email]> wrote:

| [hidden email] wrote:
| >
| > why not do this:
| >
| > system(['cp -f ' Name1 ' tmp.wav']);
| > load -ascii tmp.wav ;
| > EXTRACT YOUR DATA HERE e.g. :
| > eval(['x' Name1 '=tmp;']); clear tmp;
| > system('rm tmp.wav'); % Not necessary
| >
| > ?
|
| This is a good idea.  I knew someone would think of a better solution
| than I came up with.(a C++ dynamically linked file)  However, I think I
| will use ln rather than cp, because the files can be somewhat large.  

FWIW, Octave has unlink(), so the system command to remove the file
can be done directly without having to start a shell subprocess.
Perhaps it should also have link(), symlink(), and readlink(), since
they would be fairly trivial to add.

Also, if you are going to copy (or link) the file to some other name,
why not make it the name of the variable that you want to load?  Then
you don't have to copy the data from a temporary name.  Perhaps it is
best to do this in some subdirectory.  Something like

  mkdir ("some tmp directory");
  chdir ("some tmp directory");
  link (old-name, new-name);    # or use system() until link is available
  load (new-name);
  unlink (new-name);
  chdir ("back where we started");

(Adding some error checking to this would probably also be a good idea.)

Of course, Octave should probably also allow

  x = load ("some-odd-file-name.dat")

so all of this would be unnecessary.  Anyone care to implement it and
submit a patch?

jwe



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

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------


Reply | Threaded
Open this post in threaded view
|

Re: load problems

Joao Cardoso-3
"John W. Eaton" wrote:
>
> On  2-Aug-2000, Ben Sapp <[hidden email]> wrote:
>

...

> Of course, Octave should probably also allow
>
>   x = load ("some-odd-file-name.dat")
>
> so all of this would be unnecessary.  Anyone care to implement it and
> submit a patch?
>
> jwe

Sure.

But making

   x = load ("some-odd-file-name.dat")

can be confusing; one could think that it is a general sintax. Instead,
why not use the standard sintax,

 - Command: load options file v1 v2 ...
     Load the named variables from the file FILE.

using v1 as the name of the variable to load to?

The included patch, for octave 2.1.31,  was made with a contex diff of 6
lines, as I have my other load-save patch in my sources.

To compile I had to use the '-fpermissive' option to gcc. Even so:

load-save.cc: In function `class octave_value_list do_load(istream &,
const   string &, bool, load_save_format, oct_mach_info::float_format,
bool, bool, bool,  bool, const string_vector &, int, int, int)':
load-save.cc:3067: warning: assignment to `char *' from `const char *'
discards qualifiers

ah, how I hate C++! But I'm not a programmer, just a quick hacker!
(cat|asm :-)

Joao

load-save.cc.patch (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: load problems

John W. Eaton-6
On  3-Aug-2000, Joao Cardoso <[hidden email]> wrote:

| "John W. Eaton" wrote:
| >
| > On  2-Aug-2000, Ben Sapp <[hidden email]> wrote:
| >
|
| ...
|
| > Of course, Octave should probably also allow
| >
| >   x = load ("some-odd-file-name.dat")
| >
| > so all of this would be unnecessary.  Anyone care to implement it and
| > submit a patch?
| >
| > jwe
|
| Sure.
|
| But making
|
|    x = load ("some-odd-file-name.dat")
|
| can be confusing; one could think that it is a general sintax. Instead,
| why not use the standard sintax,

  load ("file", "option-1", "option-2");

is entirely equivalent to

  load file option-1 option-2

and works for all functions that can be invoked this way (i.e., ls,
type, who, and so on).

|  - Command: load options file v1 v2 ...
|      Load the named variables from the file FILE.
|
| using v1 as the name of the variable to load to?

Because I would think that it means load only the variables named v1,
v2, etc. from the file?

| To compile I had to use the '-fpermissive' option to gcc. Even so:
|
| load-save.cc: In function `class octave_value_list do_load(istream &,
| const   string &, bool, load_save_format, oct_mach_info::float_format,
| bool, bool, bool,  bool, const string_vector &, int, int, int)':
| load-save.cc:3067: warning: assignment to `char *' from `const char *'
| discards qualifiers

Probably you should pay attention to such warnings.  I haven't checked
your code, but discarding const is probably not what you really want
to do.

jwe



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

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------