PostgreSQL COPY csv including Quotes


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

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

However this file.csv contains data such as


as well as

random|other "stuff"|15

I tried to use the double quote to escape the quotes as the Postgres site suggested

random|other ""stuff""|15

This seems to remove the quotes completely which I don't want.
Is there a way to get the import to just treat these quotes as regular characters so that they appear in the database as they do in the csv file?

Best Solution

According to the documentation, the default quote symbol is ", so you need to provide a QUOTE argument with a different symbol. The quote symbol has to be a single one-byte character.

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