PostgreSQL COPY csv including quotes

This is a very simple problem, I am using the psql terminal COPY command as shown below.

COPY tbname FROM '/tmp/file.csv'
delimiter '|' csv;

However, this .csv file contains data such as

random|stuff|32"

and

random|other "stuff"|15

I tried using a double quote to avoid quotes as Postgres suggested

random|stuff|32""
random|other ""stuff""|15

This seems to completely eliminate quotation marks that I don't want. Is there a way to make import simply treat these quotes as regular characters so that they appear in the database just like in the csv file?

+4
source share
1 answer

, -", QUOTE . .

COPY tbname FROM '/tmp/file.csv'
delimiter '|' QUOTE '}' csv; -- use a symbol you know does not appear in your file.
+4

All Articles