I need to remove 1)line feeds) white space and blank spaces
3) any control character from my text file (abc.txt).
I tried using 'deblank' and 'strtrim' but not much success.
Any suggestions?
"sarvat " <sarvatm@yahoo.com> wrote in message
<ftftbu$2nn$1@fred.mathworks.com>...
> I need to remove 1)line feeds) white space and blank
spaces
> 3) any control character from my text file (abc.txt).
> I tried using 'deblank' and 'strtrim' but not much
success.
> Any suggestions?
>
> abc.txt
>
> /se/j1_en = OFF
> /se/j1_ag_en = ON
> /abc/j1_xyz/f0 = 0.000170
> /abc/j1_xyz/f1 = 1.001234
> /abc/j1_xyz/f2 = -1.234567
> /abc/j2_xyz/f0 = 0.939140
> /abc/j2_xyz/f1 = -0.966763
Subject: strip line feeds, white spaces, control character
"sarvat " <sarvatm@yahoo.com> wrote in message
<ftftbu$2nn$1@fred.mathworks.com>...
> I need to remove 1)line feeds) white space and blank
spaces
> 3) any control character from my text file (abc.txt).
> I tried using 'deblank' and 'strtrim' but not much
success.
> Any suggestions?
>
> abc.txt
>
> /se/j1_en = OFF
> /se/j1_ag_en = ON
> /abc/j1_xyz/f0 = 0.000170
> /abc/j1_xyz/f1 = 1.001234
> /abc/j1_xyz/f2 = -1.234567
> /abc/j2_xyz/f0 = 0.939140
> /abc/j2_xyz/f1 = -0.966763
This offers an approach:
s = textread('abc.txt','%s')
LongString = cat(2,s{:}) ;
You could use regexprep in between to remove certain
character sequences, like in
s = regexprep(s,'(/abc)','')
hth
Jos
Subject: strip line feeds, white spaces, control character
thanks yuri,
"Yuri Geshelin" <geshelin@hotmail.com> wrote in message
<ftfu0i$5vb$1@fred.mathworks.com>...
> Hi,
>
> Here is one of the solutions. Once you have read the text
> string s, do this:
>
> indx = find(s==char(13) | s==char(10) | s==' ');
> s(indx) = [];
>
> Yuri
>
> "sarvat " <sarvatm@yahoo.com> wrote in message
> <ftftbu$2nn$1@fred.mathworks.com>...
> > I need to remove 1)line feeds) white space and blank
> spaces
> > 3) any control character from my text file (abc.txt).
> > I tried using 'deblank' and 'strtrim' but not much
> success.
> > Any suggestions?
> >
> > abc.txt
> >
> > /se/j1_en = OFF
> > /se/j1_ag_en = ON
> > /abc/j1_xyz/f0 = 0.000170
> > /abc/j1_xyz/f1 = 1.001234
> > /abc/j1_xyz/f2 = -1.234567
> > /abc/j2_xyz/f0 = 0.939140
> > /abc/j2_xyz/f1 = -0.966763
>
Subject: strip line feeds, white spaces, control character
thanks jos,
this does the job, much appreciated.
regards
sarvat
"Jos " <DELjos@jasenDEL.nl> wrote in message <ftgogr$965
$1@fred.mathworks.com>...
> "sarvat " <sarvatm@yahoo.com> wrote in message
> <ftftbu$2nn$1@fred.mathworks.com>...
> > I need to remove 1)line feeds) white space and blank
> spaces
> > 3) any control character from my text file (abc.txt).
> > I tried using 'deblank' and 'strtrim' but not much
> success.
> > Any suggestions?
> >
> > abc.txt
> >
> > /se/j1_en = OFF
> > /se/j1_ag_en = ON
> > /abc/j1_xyz/f0 = 0.000170
> > /abc/j1_xyz/f1 = 1.001234
> > /abc/j1_xyz/f2 = -1.234567
> > /abc/j2_xyz/f0 = 0.939140
> > /abc/j2_xyz/f1 = -0.966763
>
>
> This offers an approach:
>
> s = textread('abc.txt','%s')
> LongString = cat(2,s{:}) ;
>
> You could use regexprep in between to remove certain
> character sequences, like in
>
> s = regexprep(s,'(/abc)','')
>
> hth
> Jos
Tags for this Thread
Add a New Tag:
Separated by commas
Ex.: root locus, bode
What are tags?
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.