Join two lines seperated by a blank line

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
xceler8
Posts: 2
Joined: Sat May 22, 2010 3:44 pm

Join two lines seperated by a blank line

Post by xceler8 »

Hi, need help with the following text file output.

I have some records where there a blank line which should be a single line taking the line above and the line below the blank line as one.
There are also lines where there is no blank lines and should remain intact, I below is a sample.

Is it possible to correct this anomaly through a regular expression, that is, joining the two lines with a " " in between the two lines and thus removing the blank line, but also keeping the line where there is no blanks untouched.???

"5","01-Dec-09","000X00195F","200910006838","XXXXXXXXXX

Reversal","0002599230342","DR","59.55","No","XXXXXEM01"
"6","01-Dec-09","000X00195F","200910006838","XXXXXXXXXX

Reversal","0008599605141","CR","59.55","No","XXXXXEM01"
"7","01-Dec-09","00001420404848","200910006840","XXXXXXXXXX

Reversal","0002599230342","DR","195.79","No","XXXXXEM01"
"8","01-Dec-09","00001420404848","200910006840","XXXXXXXXXX

Reversal","0008599605141","CR","195.79","No","XXXXXEM01"
"45","01-Dec-09","068X00017C","200911374996","checks","0006599138200","DR","2750.00","No","XXLXXXM01"
"46","01-Dec-09","068X00017C","200911374996","checks","0006599138000","CR","2750.00","No","XXLXXXM01"
"47","01-Dec-09","00001390363644","200911375102","signon","0006599138000","DR","149.76","No","XXXXXVM01"

Any help will be much appreciated if the end result would be the below:

"1","01-Dec-09","000X01016A","200910006832","XXXXXXXXXX Reversal","0002599230342","DR","924.65","No","XXXXXEM01"
"2","01-Dec-09","000X01016A","200910006832","XXXXXXXXXX Reversal","0008599605141","CR","924.65","No","XXXXXEM01"
"3","01-Dec-09","000W00072B","200910006834","XXXXXXXXXX Reversal","0002599230342","DR","2221.19","No","XXXXXEM01"
"4","01-Dec-09","000W00072B","200910006834","XXXXXXXXXX Reversal","0008599605141","CR","2221.19","No","XXXXXEM01"
"5","01-Dec-09","000X00195F","200910006838","XXXXXXXXXX Reversal","0002599230342","DR","59.55","No","XXXXXEM01"
"6","01-Dec-09","000X00195F","200910006838","XXXXXXXXXX Reversal","0008599605141","CR","59.55","No","XXXXXEM01"
"7","01-Dec-09","00001420404848","200910006840","XXXXXXXXXX Reversal","0002599230342","DR","195.79","No","XXXXXEM01"
"8","01-Dec-09","00001420404848","200910006840","XXXXXXXXXX Reversal","0008599605141","CR","195.79","No","XXXXXEM01"
"45","01-Dec-09","068X00017C","200911374996","checks","0006599138200","DR","2750.00","No","XXLXXXM01"
"46","01-Dec-09","068X00017C","200911374996","checks","0006599138000","CR","2750.00","No","XXLXXXM01"
"47","01-Dec-09","00001390363644","200911375102","signon","0006599138000","DR","149.76","No","XXXXXVM01"
"48","01-Dec-09","00001390363644","200911375102","signon","01J3699537861","CR","149.76","No","XXXXXVM01"
"49","01-Dec-09","00001390865267","200911375102","Purchase","0110099163000","DR","40000.25","No","XXXXXVM01"
"50","01-Dec-09","00001390865267","200911375102","Purchase","01J4399551300","CR","550.00","No","XXXXXVM01"
"51","01-Dec-09","00001390865267","200911375102","Purchase","0100152724000","CR","1216.25","No","XXXXXVM01"

Thanks for any help
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Replace the underscore with a space in
Find what: \n\n
Replace with: _

[X] Regular expression

Replace All
User avatar
Mike Olds
Posts: 226
Joined: Wed Sep 30, 2009 3:27 pm
Contact:

Post by Mike Olds »

Try this:

In TextPad > Search >Replace

X regular expression

Find what:

\n\n

Replace with: make sure box is empty.
Thank you, and
Best Wishes,
Obo
http://buddhadust.net/
check out the What's New? Oblog:
http://buddhadust.net/dhammatalk/dhamma ... ts.new.htm
User avatar
Mike Olds
Posts: 226
Joined: Wed Sep 30, 2009 3:27 pm
Contact:

Post by Mike Olds »

Hay Ben! How did you do that? Har. My one shot at answering (meaning being able to answer) a regex question.
Thank you, and
Best Wishes,
Obo
http://buddhadust.net/
check out the What's New? Oblog:
http://buddhadust.net/dhammatalk/dhamma ... ts.new.htm
xceler8
Posts: 2
Joined: Sat May 22, 2010 3:44 pm

Post by xceler8 »

:D ben_josephs and Mike Olds; thank you very much for the prompt and clear assistance, reg Exp works perfectly, your skills are highly appreciated.

Best regards
Post Reply