You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Nat Gross <na...@verizon.net> on 2005/01/13 01:34:53 UTC

Cleaning a text file with tons of extra CRLF's

Hi;
On Windows, I get a daily text file from another process that has tons 
of extra EOL's, which I manually delete with my editor.
How can I use Ant's filter to copy the file and strip all duplicate 
eol's? The fixeol task does not cut it. It should have an option to 
remove the eol, or replace every 2 consecutive eol's with 1.
If its a quick one for you, please advise.
Thank you.
-nat

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Cleaning a text file with tons of extra CRLF's

Posted by Nat Gross <na...@verizon.net>.
filterchains? I will need to catch up on that topic.
Thanks for the tip.
-nat

Matt Benson wrote:

>Also, have you tried using filterchains?  You can use
>the ignoreblank filter to remove blank lines.  And it
>might look a little prettier.
>
>-Matt
>
>--- Nat Gross <na...@verizon.net>
>wrote:
>
>  
>
>>Ok. Releasing ver 1.0RC <g>. (Using your reminder on
>>"
>>    
>>
>".)
>  
>
>>Also capitalizing on the fact that its an xml target
>>that needs the 
>>messaging, I can safely replace every single CRLF
>>with ....null, "", 
>>nada. Then replace every "/>" with "/>LF". Its real
>>simple and works, 
>>and achieves 99.9% of my goal. Here it is.
>>********
>><project name="replaceDupeLF" default="default"
>>basedir=".">
>>    <target name="default">
>>        <replace file="${basedir}/build370.xml" 
>>token="
>>    
>>
>" 
>  
>
>>value="" summary="true"></replace>
>>        <replace file="${basedir}/build370.xml" 
>>token="/&gt;" 
>>value="/&gt;
>>    
>>
>" summary="true"></replace>
>  
>
>>    </target>
>></project>
>>********
>>Thank you;
>>-nat
>>
>>
>>Julius Davies wrote:
>>
>>    
>>
>>>Hi, Nat,
>>>
>>>I never would have thought of that!  Really neat!
>>>
>>>Actually, "
>>>      
>>>
>" is a CR, not 015.
>  
>
>>>yours,
>>>
>>>Julius
>>>
>>>On Wed, 2005-01-12 at 21:25 -0500, Nat Gross wrote:
>>> 
>>>
>>>      
>>>
>>>>Thanks, but for whatever reason, I can't get 
>>>>        
>>>>
>>replacetoken to work, 
>>    
>>
>>>>regardless if using CDATA or plain strings.
>>>>BUT, you pointed me in the right direction and the
>>>>        
>>>>
>>following *partially* 
>>    
>>
>>>>works:
>>>><replace file="${basedir}/build370.xml" 
>>>>        
>>>>
>>token="
>>    
>>
>
>" 
>  
>
>>>>value="
>>>>        
>>>>
>" summary="true">
>  
>
>>>>However, it's only a partial solution, because it
>>>>        
>>>>
>>takes care of only 
>>    
>>
>>>>about half the white space, and heaven knows what
>>>>        
>>>>
>>the other white space 
>>    
>>
>>>>really is. Alas there is no valid  escape
>>>>        
>>>>
>>sequence. (That would 
>>    
>>
>>>>represent a CR).
>>>>
>>>>Also to Martin, alas, I'm not well versed in
>>>>        
>>>>
>>regex.
>>    
>>
>>>>-nat
>>>>
>>>>
>>>>Julius Davies wrote:
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>>>>Try this:
>>>>>
>>>>><replace file="test.txt" value="">
>>>>><replacetoken><![CDATA[
>>>>>
>>>>>]]></replacetoken>
>>>>><replacevalue><![CDATA[
>>>>>]]></replacevalue>
>>>>></replace>
>>>>>
>>>>>Be careful to make sure the CDATA only contains
>>>>>          
>>>>>
>>the EOL's and no extra
>>    
>>
>>>>>whitespace!
>>>>>
>>>>>BEFORE:
>>>>>=======================
>>>>>this file
>>>>>
>>>>>seems to be
>>>>>
>>>>>double spaced
>>>>>
>>>>>except for the
>>>>>very last line.
>>>>>
>>>>>
>>>>>AFTER:
>>>>>=======================
>>>>>this file
>>>>>seems to be
>>>>>double spaced
>>>>>except for the
>>>>>very last line.
>>>>>
>>>>>
>>>>>yours,
>>>>>
>>>>>Julius
>>>>>
>>>>>On Wed, 2005-12-01 at 19:34 -0500, Nat Gross
>>>>>          
>>>>>
>>wrote:
>>    
>>
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>Hi;
>>>>>>On Windows, I get a daily text file from another
>>>>>>            
>>>>>>
>>process that has tons 
>>    
>>
>>>>>>of extra EOL's, which I manually delete with my
>>>>>>            
>>>>>>
>>editor.
>>    
>>
>>>>>>How can I use Ant's filter to copy the file and
>>>>>>            
>>>>>>
>>strip all duplicate 
>>    
>>
>>>>>>eol's? The fixeol task does not cut it. It
>>>>>>            
>>>>>>
>>should have an option to 
>>    
>>
>>>>>>remove the eol, or replace every 2 consecutive
>>>>>>            
>>>>>>
>>eol's with 1.
>>    
>>
>>>>>>If its a quick one for you, please advise.
>>>>>>Thank you.
>>>>>>-nat
>>>>>>            
>>>>>>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Cleaning a text file with tons of extra CRLF's

Posted by Matt Benson <gu...@yahoo.com>.
Also, have you tried using filterchains?  You can use
the ignoreblank filter to remove blank lines.  And it
might look a little prettier.

-Matt

--- Nat Gross <na...@verizon.net>
wrote:

> Ok. Releasing ver 1.0RC <g>. (Using your reminder on
> "
".)
> Also capitalizing on the fact that its an xml target
> that needs the 
> messaging, I can safely replace every single CRLF
> with ....null, "", 
> nada. Then replace every "/>" with "/>LF". Its real
> simple and works, 
> and achieves 99.9% of my goal. Here it is.
> ********
> <project name="replaceDupeLF" default="default"
> basedir=".">
>     <target name="default">
>         <replace file="${basedir}/build370.xml" 
> token="
" 
> value="" summary="true"></replace>
>         <replace file="${basedir}/build370.xml" 
> token="/&gt;" 
> value="/&gt;
" summary="true"></replace>
>     </target>
> </project>
> ********
> Thank you;
> -nat
> 
> 
> Julius Davies wrote:
> 
> >Hi, Nat,
> >
> >I never would have thought of that!  Really neat!
> >
> >Actually, "
" is a CR, not 015.
> >
> >yours,
> >
> >Julius
> >
> >On Wed, 2005-01-12 at 21:25 -0500, Nat Gross wrote:
> >  
> >
> >>Thanks, but for whatever reason, I can't get 
> replacetoken to work, 
> >>regardless if using CDATA or plain strings.
> >>BUT, you pointed me in the right direction and the
> following *partially* 
> >>works:
> >> <replace file="${basedir}/build370.xml" 
> token="

" 
> >>value="
" summary="true">
> >>
> >>However, it's only a partial solution, because it
> takes care of only 
> >>about half the white space, and heaven knows what
> the other white space 
> >>really is. Alas there is no valid  escape
> sequence. (That would 
> >>represent a CR).
> >>
> >>Also to Martin, alas, I'm not well versed in
> regex.
> >>-nat
> >>
> >>
> >>Julius Davies wrote:
> >>
> >>    
> >>
> >>>Try this:
> >>>
> >>><replace file="test.txt" value="">
> >>> <replacetoken><![CDATA[
> >>>
> >>>]]></replacetoken>
> >>> <replacevalue><![CDATA[
> >>>]]></replacevalue>
> >>></replace>
> >>>
> >>>Be careful to make sure the CDATA only contains
> the EOL's and no extra
> >>>whitespace!
> >>>
> >>>BEFORE:
> >>>=======================
> >>>this file
> >>>
> >>>seems to be
> >>>
> >>>double spaced
> >>>
> >>>except for the
> >>>very last line.
> >>>
> >>>
> >>>AFTER:
> >>>=======================
> >>>this file
> >>>seems to be
> >>>double spaced
> >>>except for the
> >>>very last line.
> >>>
> >>>
> >>>yours,
> >>>
> >>>Julius
> >>>
> >>>On Wed, 2005-12-01 at 19:34 -0500, Nat Gross
> wrote:
> >>> 
> >>>
> >>>      
> >>>
> >>>>Hi;
> >>>>On Windows, I get a daily text file from another
> process that has tons 
> >>>>of extra EOL's, which I manually delete with my
> editor.
> >>>>How can I use Ant's filter to copy the file and
> strip all duplicate 
> >>>>eol's? The fixeol task does not cut it. It
> should have an option to 
> >>>>remove the eol, or replace every 2 consecutive
> eol's with 1.
> >>>>If its a quick one for you, please advise.
> >>>>Thank you.
> >>>>-nat
> >>>>
> >>>>        
> >>>>
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Cleaning a text file with tons of extra CRLF's

Posted by Nat Gross <na...@verizon.net>.
Ok. Releasing ver 1.0RC <g>. (Using your reminder on "&#013".)
Also capitalizing on the fact that its an xml target that needs the 
messaging, I can safely replace every single CRLF with ....null, "", 
nada. Then replace every "/>" with "/>LF". Its real simple and works, 
and achieves 99.9% of my goal. Here it is.
********
<project name="replaceDupeLF" default="default" basedir=".">
    <target name="default">
        <replace file="${basedir}/build370.xml"  token="&#013;&#010;" 
value="" summary="true"></replace>
        <replace file="${basedir}/build370.xml"  token="/&gt;" 
value="/&gt;&#010;" summary="true"></replace>
    </target>
</project>
********
Thank you;
-nat


Julius Davies wrote:

>Hi, Nat,
>
>I never would have thought of that!  Really neat!
>
>Actually, "&#013;" is a CR, not 015.
>
>yours,
>
>Julius
>
>On Wed, 2005-01-12 at 21:25 -0500, Nat Gross wrote:
>  
>
>>Thanks, but for whatever reason, I can't get  replacetoken to work, 
>>regardless if using CDATA or plain strings.
>>BUT, you pointed me in the right direction and the following *partially* 
>>works:
>> <replace file="${basedir}/build370.xml"  token="&#010;&#010;" 
>>value="&#010;" summary="true">
>>
>>However, it's only a partial solution, because it takes care of only 
>>about half the white space, and heaven knows what the other white space 
>>really is. Alas there is no valid &#015; escape sequence. (That would 
>>represent a CR).
>>
>>Also to Martin, alas, I'm not well versed in regex.
>>-nat
>>
>>
>>Julius Davies wrote:
>>
>>    
>>
>>>Try this:
>>>
>>><replace file="test.txt" value="">
>>> <replacetoken><![CDATA[
>>>
>>>]]></replacetoken>
>>> <replacevalue><![CDATA[
>>>]]></replacevalue>
>>></replace>
>>>
>>>Be careful to make sure the CDATA only contains the EOL's and no extra
>>>whitespace!
>>>
>>>BEFORE:
>>>=======================
>>>this file
>>>
>>>seems to be
>>>
>>>double spaced
>>>
>>>except for the
>>>very last line.
>>>
>>>
>>>AFTER:
>>>=======================
>>>this file
>>>seems to be
>>>double spaced
>>>except for the
>>>very last line.
>>>
>>>
>>>yours,
>>>
>>>Julius
>>>
>>>On Wed, 2005-12-01 at 19:34 -0500, Nat Gross wrote:
>>> 
>>>
>>>      
>>>
>>>>Hi;
>>>>On Windows, I get a daily text file from another process that has tons 
>>>>of extra EOL's, which I manually delete with my editor.
>>>>How can I use Ant's filter to copy the file and strip all duplicate 
>>>>eol's? The fixeol task does not cut it. It should have an option to 
>>>>remove the eol, or replace every 2 consecutive eol's with 1.
>>>>If its a quick one for you, please advise.
>>>>Thank you.
>>>>-nat
>>>>
>>>>        
>>>>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Cleaning a text file with tons of extra CRLF's

Posted by Julius Davies <ju...@cucbc.com>.
Hi, Nat,

I never would have thought of that!  Really neat!

Actually, "&#013;" is a CR, not 015.

yours,

Julius

On Wed, 2005-01-12 at 21:25 -0500, Nat Gross wrote:
> Thanks, but for whatever reason, I can't get  replacetoken to work, 
> regardless if using CDATA or plain strings.
> BUT, you pointed me in the right direction and the following *partially* 
> works:
>  <replace file="${basedir}/build370.xml"  token="&#010;&#010;" 
> value="&#010;" summary="true">
> 
> However, it's only a partial solution, because it takes care of only 
> about half the white space, and heaven knows what the other white space 
> really is. Alas there is no valid &#015; escape sequence. (That would 
> represent a CR).
> 
> Also to Martin, alas, I'm not well versed in regex.
> -nat
> 
> 
> Julius Davies wrote:
> 
> >Try this:
> >
> ><replace file="test.txt" value="">
> >  <replacetoken><![CDATA[
> >
> >]]></replacetoken>
> >  <replacevalue><![CDATA[
> >]]></replacevalue>
> ></replace>
> >
> >Be careful to make sure the CDATA only contains the EOL's and no extra
> >whitespace!
> >
> >BEFORE:
> >=======================
> >this file
> >
> >seems to be
> >
> >double spaced
> >
> >except for the
> >very last line.
> >
> >
> >AFTER:
> >=======================
> >this file
> >seems to be
> >double spaced
> >except for the
> >very last line.
> >
> >
> >yours,
> >
> >Julius
> >
> >On Wed, 2005-12-01 at 19:34 -0500, Nat Gross wrote:
> >  
> >
> >>Hi;
> >>On Windows, I get a daily text file from another process that has tons 
> >>of extra EOL's, which I manually delete with my editor.
> >>How can I use Ant's filter to copy the file and strip all duplicate 
> >>eol's? The fixeol task does not cut it. It should have an option to 
> >>remove the eol, or replace every 2 consecutive eol's with 1.
> >>If its a quick one for you, please advise.
> >>Thank you.
> >>-nat
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> >>For additional commands, e-mail: user-help@ant.apache.org
> >>
> >>    
> >>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> >For additional commands, e-mail: user-help@ant.apache.org
> >
> >
> >  
> >
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Cleaning a text file with tons of extra CRLF's

Posted by Nat Gross <na...@verizon.net>.
Thanks, but for whatever reason, I can't get  replacetoken to work, 
regardless if using CDATA or plain strings.
BUT, you pointed me in the right direction and the following *partially* 
works:
 <replace file="${basedir}/build370.xml"  token="&#010;&#010;" 
value="&#010;" summary="true">

However, it's only a partial solution, because it takes care of only 
about half the white space, and heaven knows what the other white space 
really is. Alas there is no valid &#015; escape sequence. (That would 
represent a CR).

Also to Martin, alas, I'm not well versed in regex.
-nat


Julius Davies wrote:

>Try this:
>
><replace file="test.txt" value="">
>  <replacetoken><![CDATA[
>
>]]></replacetoken>
>  <replacevalue><![CDATA[
>]]></replacevalue>
></replace>
>
>Be careful to make sure the CDATA only contains the EOL's and no extra
>whitespace!
>
>BEFORE:
>=======================
>this file
>
>seems to be
>
>double spaced
>
>except for the
>very last line.
>
>
>AFTER:
>=======================
>this file
>seems to be
>double spaced
>except for the
>very last line.
>
>
>yours,
>
>Julius
>
>On Wed, 2005-12-01 at 19:34 -0500, Nat Gross wrote:
>  
>
>>Hi;
>>On Windows, I get a daily text file from another process that has tons 
>>of extra EOL's, which I manually delete with my editor.
>>How can I use Ant's filter to copy the file and strip all duplicate 
>>eol's? The fixeol task does not cut it. It should have an option to 
>>remove the eol, or replace every 2 consecutive eol's with 1.
>>If its a quick one for you, please advise.
>>Thank you.
>>-nat
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>For additional commands, e-mail: user-help@ant.apache.org
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>
>  
>


Re: Cleaning a text file with tons of extra CRLF's

Posted by Julius Davies <ju...@cucbc.com>.
Try this:

<replace file="test.txt" value="">
  <replacetoken><![CDATA[

]]></replacetoken>
  <replacevalue><![CDATA[
]]></replacevalue>
</replace>

Be careful to make sure the CDATA only contains the EOL's and no extra
whitespace!

BEFORE:
=======================
this file

seems to be

double spaced

except for the
very last line.


AFTER:
=======================
this file
seems to be
double spaced
except for the
very last line.


yours,

Julius

On Wed, 2005-12-01 at 19:34 -0500, Nat Gross wrote:
> Hi;
> On Windows, I get a daily text file from another process that has tons 
> of extra EOL's, which I manually delete with my editor.
> How can I use Ant's filter to copy the file and strip all duplicate 
> eol's? The fixeol task does not cut it. It should have an option to 
> remove the eol, or replace every 2 consecutive eol's with 1.
> If its a quick one for you, please advise.
> Thank you.
> -nat
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Cleaning a text file with tons of extra CRLF's

Posted by Martin Cooper <ma...@apache.org>.
You might try the (optional) <replaceregexp> task.

--
Martin Cooper


On Wed, 12 Jan 2005, Nat Gross wrote:

> Hi;
> On Windows, I get a daily text file from another process that has tons of 
> extra EOL's, which I manually delete with my editor.
> How can I use Ant's filter to copy the file and strip all duplicate eol's? 
> The fixeol task does not cut it. It should have an option to remove the eol, 
> or replace every 2 consecutive eol's with 1.
> If its a quick one for you, please advise.
> Thank you.
> -nat
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org