Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

replacing blank lines in a file using a efficeint approach

Solved Go to solution
Highlighted

replacing blank lines in a file using a efficeint approach

Contributor

Hi All,

Thanks a lot this awesome community. I using replace text processor and I used the apporaches such as desribed in these 2 links below

https://community.hortonworks.com/questions/147405/replacing-new-lines-weird-behavior-observed.html

https://community.hortonworks.com/questions/147226/replacetextprocessor-remove-blank-lines.html

this consumes a lot of heap space and need something efficient, @Matt Clarke suggested to use shown in picture.

47429-sample.png

Now I am using

Evaluation mode as Line by line

Search regex as ^ (new line shift+enter) $

What should be my replacement value?

since there are no groups formed there?

Any help or suggestions?

Thanks a lot

1 ACCEPTED SOLUTION

Accepted Solutions

Re: replacing blank lines in a file using a efficeint approach

Super Guru
@dhieru singh

I think just add capture all after $ as shown below screenshot will work.

Search Value

^ 
$(.*)

Replacement Value

$1

Replacement Strategy

Regex Replace

Evaluation Mode

Line-by-Line

Replace Text Configs:-

47435-replacetext.png

4 REPLIES 4

Re: replacing blank lines in a file using a efficeint approach

Super Guru
@dhieru singh

I think just add capture all after $ as shown below screenshot will work.

Search Value

^ 
$(.*)

Replacement Value

$1

Replacement Strategy

Regex Replace

Evaluation Mode

Line-by-Line

Replace Text Configs:-

47435-replacetext.png

Re: replacing blank lines in a file using a efficeint approach

Contributor

@Shu Thanks for the response. However it still did not removed the blank lines. Attached is the image,

47436-befroe1.png

and after applying replacetext processor it still looked the same

47437-after1.png

Any idea or help?

Thanks

Dheeru

Re: replacing blank lines in a file using a efficeint approach

Super Guru
@dhieru singh

Can you once make sure the search value property having no spaces in it.

Search Value

^//no space
$(.*)//no space

Configs:-

47441-replacetext.png

Compare your Replace Text processor configs with above screenshot configs and don't keep any spaces after ^ and $(.*) in search value property and Rerun the processor.

If you are still having issues please attach your input file contents...!!

Re: replacing blank lines in a file using a efficeint approach

Contributor

@Shu it worked Thanks a lot appreciate your help!!!. Apologies for the silly mistake, there was a space on the first line

Thanks again

Don't have an account?
Coming from Hortonworks? Activate your account here