BUG #16424: COPY Command fails for CSV formath

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: vivek4422(at)gmail(dot)com
Subject: BUG #16424: COPY Command fails for CSV formath
Date: 2020-05-08 07:42:23
Message-ID: 16424-e8b18e8aa3bbd0c8@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16424
Logged by: Vivek Kamath
Email address: vivek4422(at)gmail(dot)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.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Volodymyr Blahoi 2020-05-08 10:18:36 pg_dump
Previous Message bucoo@sohu.com 2020-05-08 07:13:34 a bug for shm_mq