[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: save function
From: |
Mike Miller |
Subject: |
Re: save function |
Date: |
Wed, 9 Mar 2005 01:02:34 -0600 (CST) |
On Tue, 8 Mar 2005, John W. Eaton wrote:
On 8-Mar-2005, Robert A. Macy <address@hidden> wrote:
| My two cents...
|
| Leave alone save function
|
| I have not experienced any problems with it. If I don't
| want the header, I throw it away.
I think that's a good solution, but apparently some people want
bug-for-bug(*) compatibility.
In any case, I would not do away with Octave's save format. The
question is whether it is worth making the backwardly incompatible (for
Octave) but compatible (with Matlab) change so that -ascii works as it
does in Matlab. We would move the current -ascii behavior to a
different option, perhaps -oct-ascii or -text or something.
--------
* Though I suppose one person's bug is another's prized feature...
There are two distinct issues. One is MATLAB compatibility. The other is
the annoying header lines. The header lines can be useful, but there are
many situations in which I do not want them. I can tell that many other
people often do not want them. They are useful primarily when the data
are to be read back into Octave. When the data are going to another
program, the header lines often have to be removed.
Robert Macy suggests that when he doesn't want the header lines, he throws
them away. That's what I do too. For example, see the little perl script
I wrote below. In any collection of text files, it removes all initial
consecutive lines that begin with '# ' (without the quotes) when the
following line begins with a space. You could name the script
'remove_octave_headers', make sure the path to perl is correct for your
system, then run it like this to fix all the Octave ascii output files in
the default directory:
remove_octave_headers *.out
It replaces all of the original .out files with the headerless files. If
the file has multiple headers (multiple variables), it ignores the later
headers (but that behavior could be changed). I am assuming that a line
beginning with a space always follows the last line of the header.
Sometimes I generate 10,000 data files from Octave, then I have to run
this script on those 10,000 files to remove the headers. It would be nice
if I could just create the data without the header lines in the first
place.
Regarding MATLAB compatibility - we don't want to do what MATLAB is doing
(converting strings to numbers, deleting the imaginary parts of complex
numbers, etc.). How about having "save -ascii" produce a space-delimited
text file with all of the requested variables in it, and no header? This
would be the sort of thing one would expect. It would be more nearly
compatible with MATLAB (not aligned in columns, but space delimited) and
without the bug (dropping imaginary parts) or the weirdness (converting
letters to numbers). For storing a single matrix, it would do what I
think most people would expect. Don't we use the -ascii option to export
to other programs? If so, the header will usually get in the way.
Mike
------------------------begin script on next line----------------------
#!/usr/bin/perl -i -p
# This removes the initial header lines of an octave ascii data file
BEGIN{undef $/} s/(# [^\n]+\n)+ / /
------------------------end script on previous line--------------------
-------------------------------------------------------------
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
-------------------------------------------------------------
- Re: save function, (continued)
- Re: save function, Paul Kienzle, 2005/03/06
- Re: save function, Mike Miller, 2005/03/06
- Re: save function, Paul Kienzle, 2005/03/06
- Re: save function, Mike Miller, 2005/03/06
- Re: save function, John W. Eaton, 2005/03/08
- Re: save function, John W. Eaton, 2005/03/08
- Re: save function, Hamish Allan, 2005/03/08
- Re: save function, Francesco Potorti`, 2005/03/08
- Re: save function, Robert A. Macy, 2005/03/08
- Re: save function, John W. Eaton, 2005/03/08
- Re: save function,
Mike Miller <=
- Re: save function, Hamish Allan, 2005/03/09
- Re: save function, David Bateman, 2005/03/09
- Re: save function, John W. Eaton, 2005/03/09
- Re: save function, Hamish Allan, 2005/03/09
- Re: save function, John W. Eaton, 2005/03/09
- Re: save function, Mike Miller, 2005/03/09
- Re: save function, Francesco Potorti`, 2005/03/09
- Re: save function, John W. Eaton, 2005/03/09
- Re: save function, Francesco Potorti`, 2005/03/10
- Re: save function, mavram, 2005/03/09