[Top][All Lists]

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

Re: How to save ascii files without header information

From: Mike Miller
Subject: Re: How to save ascii files without header information
Date: Wed, 16 Apr 2003 11:28:02 -0500 (CDT)

On Wed, 29 Jan 2003, Andrass Ziska Davidsen wrote:

> On Wednesday 29 January 2003 14:56, Poul-Erik Hansen wrote:
> > When you save data with he save -ascii command, octave puts
> > information about who has generate the file, number of rows and number
> > of columns in the top of the file. Is there a way too tell octave not
> > to save this information?
> This has also pussled me, and the workaround that I found was to use the
> fprintf command. Look it up in the 'help fprintf'. It is quite similar,
> if not exactly the same, as the one used in C.

I just developed a super-simple post-processing perl script for removing
the extra comment lines in the saved file.  It actually removes any lines
beginning with '# ' (pound followed by space), but it would be rare (if it
isn't impossible) to have such lines anywhere in the saved ascii file
except for the comments on the first few lines.  Here is the simple perl

#!/usr/bin/perl -i -p
s/^# .*\n$//

Just put it in your path, chmod to make it executable, and edit the first
line if the path to the perl executable is not correct for your system
(e.g., it's sometimes /usr/local/bin/perl instead of /usr/bin/perl).  I
called mine "strip_comments."  It can be used like this:

strip_comments data/* octave/*.dat

Where all of the arguments are patterns matching to filenames.  The script
will alter all of the files matching the patterns and it will not prompt
you before doing so.  So be careful of what you ask it to do!  It is
dangerous if used recklessly.



Michael B. Miller, Ph.D.
Assistant Professor
Division of Epidemiology
and Institute of Human Genetics
University of Minnesota

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]