Reputation: 271
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.
Upvotes: 0
Views: 625
Reputation: 4708
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
Upvotes: 1