Removing \n from .csv file

Hi,

I have a requirement like my .csv file is generating from a db2 table using export command like below:

file format:
-----------

2011	4	0	0	N	S	C		C	"BHPC
BHPC"	0	0	0
2011	5	0	0	N	S	C		C	"BHPC
BHPC"	0	0	0

here BHPC is having new line character and because this when i am trying to load this file to a table it is loading in two rows and this should not be done.
please help me to delete the \n character in between "BHPC
BHPC" with unix commands and at the same time it should load into the table with BHPC BHPC.
I have searched in the forun but couldn`t able to find out the solution.
Please let me know if you want anyother information on this.

Thanks In Advance
Varma.

Do you mean like this?

awk '$NF=="\"BHPC"{getline p; $0=$0 OFS p}1' file

Does that field have a newline stored in the database? If so wouldn't it be better to remove it using a database function?

Or if it doesn't have a newline in the database, is it just that you need to increase the line size?

Hi,

Actually from the database the value is coming like C "BHPC
BHPC" 0 0
and if i looked it in unix environment by doing awk -F "," {print $35} with the file it is showing like

"BHPC
N
"BHPC
N
.
.
.
like this..

sorry I don`t have information on the database like how it was stored.

Regards,
pradeep.

hey Varma,

please use the below code.

#This one-liner also starts with creating a named label "a". Then it tests to see if it is not the last line and appends the next line to the current one with "N" command. If the just appended line starts with a "BHPC", one-liner branches the label "a" to see if there are more lines starting with "BHPC". During this process a substitution gets executed which throws away the newline character which came from joining with "N" and the "BHPC". If the substitution fails, one-liner prints out the pattern space up to the newline character with the "P" command, and deletes the contents of pattern space up to the newline character with "D" command, and repeats the process.

sed -e :a -e '$!N;s/\nBHPC/ BHPC/;ta' -e 'P;D' $file