Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to remove unwanted text from a .txt file?
Date: Wed, 24 Sep 2008 00:35:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 42
Message-ID: <gbc1vn$8k6$1@fred.mathworks.com>
References: <gbbqun$qo5$1@fred.mathworks.com> <ryeCk.36464$QF5.28064@newsfe08.iad> <gbbubd$2n7$1@fred.mathworks.com> <VGfCk.562$Cl1.66@newsfe01.iad>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1222216503 8838 172.30.248.37 (24 Sep 2008 00:35:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 24 Sep 2008 00:35:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1248302
Xref: news.mathworks.com comp.soft-sys.matlab:491678


Walter Roberson <roberson@hushmail.com> wrote in message <VGfCk.562$Cl1.66@newsfe01.iad>...
> Cy abd top-posted:
> 
> Please do not post your reply above the material you are commenting on: it makes
> it difficult to hold a discussion.
> 
> >> perl, sed, ed, awk, grep, C, matlab, ...
> 
> > how about just the matlab way, since I'm posting in the matlab forum? care to
> > maybe hint on that?
> 
> The matlab way that -I- would use would be to write a short perl script to do
> the work. Matlab arrives with perl installed, accessible via the perl() command.
> 
> For example, put this in file allbut.pl
> 
> $refuse = shift @ARGV; while (<>) { print unless /(?:$refuse)/o; }
> 
> 
> Then to use it, in matlab call with (e.g.)
> 
> filteredtext = perl('allbut.pl', 'Lost data connection|Reconnecting', 'XYZ.txt');
> 
> where XYZ.txt is the file name of the file to have the lines removed,
> and the lines to be deleted are any lines that contain either the string
> 'Lost data connection' or the string 'Reconnecting' anywhere on the line.
> 
> The result variable, filteredtext, would probably be a char vector
> (with embedded end of line characters) containing all the -other- lines.
> You could write that to a file if you wanted, or it might be more convenient
> to textscan() the string without writing it out to a file.
> 
> 
> The same task can certainly be done without calling out to perl, but
> it is more of a nuisance.

Thank you for the explanation, will get working on it and hopefully will be able to resolve my problem. 

Sorry about the TOP posting always used to think that is the riht way, won't happen again though.

One would have thought that ML would have implemented an straight forward solution for such a popular problem within the textscan but unfortunately NOT! It can ignore strings but not complete lines stating with a string! Although I maybe wrong, I'm also looking into commentStyle which might just do that, does it?
thanks again