0

I am trying to import datas into postgresql. Windows 7, 64 bit. My SQL Code is as follows:

CREATE TABLE films (
  imdib varchar,
  name varchar,
  year integer,
  rating integer,
  votes integer,
  runtime time,
  directors varchar,
  actors varchar,
  genres varchar
);

my Copy code is:

 COPY films from 'C:\Users\Max\Desktop\imdb_top100.txt' DELIMITER ',';

My imdb_top100.txt contains this:

tt0111161   The Shawshank Redemption    1994    9.3 1462391 142 mins.   Frank Darabont  Tim Robbins|Morgan Freeman|Bob Gunton   Crime|Drama 

Getting this Error on Postgresql:

ERROR: missing datas for column „name“

CONTEXT: COPY films, Line 1: „tt0111161 The Shawshank Redemption 1994 9.3 1462391 142 mins. Frank Darabont Tim Robbins|Morgan F...“ ********** Error **********

1 Answer 1

3

Your data is TAB delimited, not comma delimited. So you have to specify tab character as delimiter:

COPY films from 'C:\Users\Max\Desktop\imdb_top100.txt' DELIMITER '\t';

Source

The error reported informs that as there where no comma found, all the line corresponds to the first field, and there is no data left for the following field (name).

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.