Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

replacing blank lines in a file using a efficeint approach

avatar
Expert 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

avatar
Master 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

View solution in original post

4 REPLIES 4

avatar
Master 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

avatar
Expert 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

avatar
Master 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...!!

avatar
Expert 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