awk to find and replace Double quotes between pipes

Hello,

Need a AWK command to find and replace Double Quotes in Pipe delimited files

Actully its a CSV file converted to Pipe but the double quotes still exists. So i want to Get rid of them.

Example

Input

1|2|3|sadsad|"Abc Efg 3"""|dada

Output

1|2|3|sadsad|Abc Efg 3"|dada

Thanks

sed 's/""|/|/g' < input > output

With awk :

awk '{gsub(/\"[|]/, "|"); gsub(/[|]\"/, "|"); gsub(/\"\"/, "\""); print}' input

With sed :

sed -e 's/"|/|/g' -e 's/|"/|/g' -e 's/""/"/g' input

Another replace is needed if first field can be quoted:

awk '{gsub(/^"/,"");gsub(/\"[|]/, "|"); gsub(/[|]\"/, "|"); gsub(/\"\"/, "\""); print}' input
sed -e 's/^"//' -e 's/"|/|/g' -e 's/|"/|/g' -e 's/""/"/g' input

Good catch, but still not complete. We also have to worry about quotes in the last field:

awk '{gsub(/^\"|\"$/, ""); gsub(/\"[|]/, "|"); gsub(/[|]\"/, "|"); gsub(/\"\"/, "\""); print}' input
sed -e 's/"$//' -e 's/^"//' -e 's/"|/|/g' -e 's/|"/|/g' -e 's/""/"/g' input

Why is there a double quote remaining? Is this the kind of CSV escape that a repeated double quote inside double quotes means a single double quote? This is not mentioned in the description, which just says get rid of the double quotes. Try:

awk -F\" '{for(i=2; i<NF; i++) if($i=="") $(i++)=FS}1' OFS= file

What do we do with possible pipe symbols inside those double quotes?