0

I have a problem when I want to copy data from a csv-file to a postgresql database. I follow the steps from: https://github.com/gregrahn/join-order-benchmark and everything works fine untill I'm supposed to read the data from the csv file. I write the following command:

imdbload=# \copy aka_name FROM 'PATH/aka_name.csv' DELIMITER ',' CSV

And I get the same error with:

imdbload=# \copy aka_name FROM 'PATH/aka_name.csv' CSV

And get the following error:

> ERROR:  extra data after last expected column
CONTEXT:  COPY aka_name, line 126725: "25636,67744,"Atkinson, Chaz 'We'll Sail Without 'em\"",,A3252,C2424,,edfa0800ce7af314e22581f2cd102d0..."
imdbload=# 

Do anybody know what might be wrong?

2
  • 1
    Generally this happens when there is a mismatch between the number fields of data in the CSV file and the number of fields in the table. So what is the table structure and what is the file structure? Commented Aug 16, 2020 at 15:30
  • 1
    It can also happen if there is a delimiter/quoting issue that splits a field from the file into more then one column. Commented Aug 16, 2020 at 17:03

1 Answer 1

1

This is caused by \". You should specify escape like the following:

\copy aka_name from 'aka_name.csv' csv escape '\';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.