help-octave
[Top][All Lists]
Advanced

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

Re: preventing an empty last line in text files produced by dlmwrite


From: Avraham Rosenberg
Subject: Re: preventing an empty last line in text files produced by dlmwrite
Date: Tue, 15 May 2007 09:37:56 +0300
User-agent: Mutt/1.5.9i

On Sun, May 13, 2007 at 08:13:40PM -0700, Shelleyb wrote:
> 
> Hi,
> 
> Yes, my OS is Windows and I installed Cygwin before using Octave.
> 
> I tried grep -v ^$ <data.dat >data1.dat at the Octave command prompt, and
> only received an error message about syntax (invalid character "$" (ASCII
> 36)).
> 
> I tried the same in the Cygwin shell, and there were no syntax errors, but
> the data1.dat file generated still had a blank line at the end.
> 
> I reinstalled grep from the Cygwin setup, but this did not help.
> 
> Have you had success using 'grep' within Octave? Is there another package
> that I need to install in order to get it to work. Maybe the syntax in
> Octave is wrong.
> 
> Thanks!
> 
Hi,
Your second guess was right: The command should be issued at the
cygwin prompt. Sorry for not mentioning that in the first place.
As for failure, I can see four possibilities:
1-I made a mistake (or maybe the mail distorted somewhat my
message).
2-You made some mistake.
3-The line you wished to get rid of was not really empty, but
contained some (invisible) character(s).
4-Your check was wrong.

The safest way to proceed, is to send the file data.dat along. If
it is too big, just send its beginning and its end.
Simplest way to get those:
head data.dat >headsample
tail data.dat >tailsample
   At the cygwin prompt.
In this way, I'll be able to check my advice before sending it.

If the matter is very urgent, or you are very impatient, you can
try:
grep [0-9] data.dat >data1.dat, at the cygwin prompt,
   which selects all the lines containing at least a digit.
   (If your header line contains no digit you obtain just the
   array, which you can then load into octave, just by using 
   load "data1.dat"
Or, if you wish to keep the headers,
grep [0-9A-Za-z] data.dat >data1.dat, at the cygwin prompt,

Cheers, Avraham

-- 
Please avoid sending to this address attachments in excess of 2MByte, 
or any Excell or Powerpoint attachments.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]