Page 1 of 1

Join two lines seperated by a blank line

Posted: Sat May 22, 2010 4:00 pm
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

Posted: Sat May 22, 2010 7:31 pm
by ben_josephs
Replace the underscore with a space in
Find what: \n\n
Replace with: _

[X] Regular expression

Replace All

Posted: Sat May 22, 2010 7:34 pm
by Mike Olds
Try this:

In TextPad > Search >Replace

X regular expression

Find what:

\n\n

Replace with: make sure box is empty.

Posted: Sat May 22, 2010 7:35 pm
by Mike Olds
Hay Ben! How did you do that? Har. My one shot at answering (meaning being able to answer) a regex question.

Posted: Sat May 22, 2010 9:38 pm
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