0

I want import in PostgreSQL csv table with next structure:

1,qw,sdf,ty
2,efw,sd,hj,gh,hj
3,sfd,sd,gf,gh,h
4,fg,sd,dff

I use sql query:

CREATE TABLE test("nom" integer, "f1" text, "f2" text, "f3" text, "f4" text, "f5" text);

COPY bptable("nom", "f1", "f2", "f3", "f4", "f5")
FROM 'D:\data.csv'
WITH DELIMITER ',' CSV;

But receive exception: ERROR: extra data after last expected column SQL state: 22P04, row 2. Hope someone can help. Advance thanks.

1
  • 1
    That's a malformed CSV file. You are missing the trailing commas after the last column in rows 1 and 4 (both are missing two column values).
    – bma
    Commented Jul 18, 2013 at 21:17

1 Answer 1

1

I've never imported data using CSV before, but you have 4 'columns' in your CSV file (line 1 and 4) and 5 columns in your SQL table.

EDIT: You will need to specifiy which column is missing data as so:

1,bla1,bla2,,bla3

Note the double coma between bla2 and bla3

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.