Blnpwr
Blnpwr

Reputation: 1875

SQL - Postgresql ERROR

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 **********

Upvotes: 0

Views: 78

Answers (1)

1010
1010

Reputation: 1848

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).

Upvotes: 3

Related Questions