CSV file issue

Hi All,
We have a csv file.
We need to read end character , if the end character is not " we need to append that line and the next one
Kindly help me to write a script

Thanks

Please post a representative sample of input and expected output

if the end of the line is not " then we need to append the current line and the next line

---------- Post updated at 04:59 AM ---------- Previous update was at 04:57 AM ----------

first line " santa
second line world"
third line "samta worldwide"

Output should be
"santa world"
"samta worldwide"

thru sed..

sed '/[^"]$/N; s/\n/ /' inputfile > outfile

thanks Michael
Will that be possible to skip the first line
Because first line will be header

---------- Post updated at 06:15 AM ---------- Previous update was at 06:09 AM ----------

sed '/[^"]$/N; s/\n/ /' inputfile > outfiledidnt work

can you paste a sample of your input file..?

A EMP 58
; NO EMP"
NO EMPL"
TXN 58
; NO EMPL"
output to be
A EMP 58 ; NO EMP"
NO EMPL" -- No change as it ends with double quotes
TXN 58 ; NO EMPL"

Ok.. It works for me..

sed '/[^"]$/N; s/\n/ /' inputfile
A EMP 58 ; NO EMP"
NO EMPL"
TXN 58 ; NO EMPL"

Is this what you expect or something else..

Attaching you correct file

Name comment value
"A","EMP","58.s
; NO EMP"
"B","EMP","56.s; NO EMPL"
"C","EMP","54.s
; NO EMP"
output to be
Name comment value
"A","EMP","58.s; NO EMP"
"B","EMP","56.s; NO EMPL" -- No change as it ends with "
"C","EMP","54.s; NO EMP"

Output got is
Name comment value"A","EMP","58.s; NO EMP"
"B","EMP","56.s; NO EMPL" "C","EMP","54.spls help

ok so you need to exempt line# 1.Could try..

tail +2 inputfile |sed '/[^"]$/N; s/\n/ /'
"A","EMP","58.s ; NO EMP"
"B","EMP","56.s; NO EMPL"
"C","EMP","54.s ; NO EMP"

not only that, if you see the output 2nd and 3rd line are merged

Name comment value
"A","EMP","58.s
; NO EMP"
"B","EMP","56.s; NO EMPL"
"C","EMP","54.s
; NO EMP"

Output got is
Name comment value"A","EMP","58.s; NO EMP"
"B","EMP","56.s; NO EMPL" "C","EMP","54.s

Well.. It works for me. Wot machine and the sed version you have..? Below is the output i get. Post your execution line as well..

cat inputfile
Name comment value
"A","EMP","58.s
; NO EMP"
"B","EMP","56.s; NO EMPL"
"C","EMP","54.s
; NO EMP"
tail +2 inputfile |sed '/[^"]$/N; s/\n/ /'
"A","EMP","58.s ; NO EMP"
"B","EMP","56.s; NO EMPL"
"C","EMP","54.s ; NO EMP"

i'm directing output to another file will that be problem
tail +1 test.csv|sed '/[^"]$/N; s/\n/ /'>test2.csv

nawk '{x=(/;/||NR<2)?RS:"";printf"%s"x,$0}' input
# cat input
Name comment value
"A","EMP","58.s
; NO EMP"
"B","EMP","56.s; NO EMPL"
"C","EMP","54.s
; NO EMP"
# nawk '{x=(/;/||NR<2)?RS:"";printf"%s"x,$0}' input
Name comment value
"A","EMP","58.s; NO EMP"
"B","EMP","56.s; NO EMPL"
"C","EMP","54.s; NO EMP"

Can you try with: tail +2 .. in the above command

sed '
1b
:o
/"$/b
N
s/\n/ /
to' test.csv