BUG #16424: COPY Command fails for CSV formath - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #16424: COPY Command fails for CSV formath
Date
Msg-id 16424-e8b18e8aa3bbd0c8@postgresql.org
Whole thread Raw
Responses Re: BUG #16424: COPY Command fails for CSV formath  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      16424
Logged by:          Vivek Kamath
Email address:      vivek4422@gmail.com
PostgreSQL version: 10.6
Operating system:   Linux Unix
Description:

Hi,

I am copying a csv file where the fields are quoted with " and separated  by
,.  
I am using below syntax to copy data using below syntax

psql -c "COPY table_name from filename WITH (FORMAT csv)".

On Analysis I observed that any data that even number of double quotes in it
are copied successfully but fails when it has odd number of double quotes in
it.
For ex
1234,"Test "hi"  ","Test bye"   will be loaded as 1234,Test hi, Test bye in
table successfully but my expectation is to load data as 1234,Test "hi",
Test bye
where as
1234,"Test "hi  ", "Test bye"  will fail with error ERROR:  unterminated CSV
quoted field.. In this case my expectation is to load data as 1234,Test "hi,
Test bye.

Also since all this is is happening as part of the batch. I cannot
pre-process the data as the same data set needs to be loaded in Redshift DB.
Copy command works perfectly fine with this data set in redshift.

Idea is load whatever comes in between the double quotes ("......") as is in
varchar field.
Please suggest some ideas as how this can be achieved.


pgsql-bugs by date:

Previous
From: "bucoo@sohu.com"
Date:
Subject: a bug for shm_mq
Next
From: Volodymyr Blahoi
Date:
Subject: pg_dump