1

I am trying to import a CSV file into Posgres that has a comma as delimiter. I do:

\COPY products(title, department) from 'toyd.csv' with (DELIMITER ',');

All super cool.

However, title and department are both strings. I have some commas that are in these columns that I don't want to be interpreted as delimiters. So I pass the strings in quotes. But this doesn't work. Postgres still thinks they are delimiters. What are my missing?

Here is a snippet from the CSV that causes the problem:

"Light","Reading, Writing & Spelling"

Any ideas?

4
  • How are the commas escaped? There are different patterns but the two I am familiar with is ',,' == ',' or '\,' = ','. If I remember correctly the previous is a more standard csv. Commented Aug 29, 2013 at 14:24
  • 1
    If these quotes are double quotes, this should work. Otherwise, maybe show a part of your CSV file. Commented Aug 29, 2013 at 14:27
  • If it is possible, then you can try changing the delimiter manually and then importing it. Commented Aug 29, 2013 at 14:58
  • stackoverflow.com/questions/10001651/… Commented Aug 29, 2013 at 14:59

1 Answer 1

3

You aren't using CSV format there, just a comma-delimited one.

Tell it you want FORMAT CSV and it should default to quoted text - you could also change the quoting character if necessary.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.