Help needed in skipping column for copy command

From: "Amar Dhole" <adhole(at)tibco(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Help needed in skipping column for copy command
Date: 2011-01-17 13:59:24
Message-ID: B290BFEC59278744B17A7A3CB14307E90387304A@NA-PA-VBE04.na.tibco.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have table created as follows

CREATE TABLE D_2147483927_2147484848_TAB(

CP VARCHAR(256) ,

CPR VARCHAR(256) ,

CHOUSENO VARCHAR(256) ,

CSTREET VARCHAR(256) ,

CLOCALITY VARCHAR(256) ,

CCITY VARCHAR(256) ,

CPROVINCE VARCHAR(256) ,

CCOUNTRY VARCHAR(256) ,

CZIP VARCHAR(256) ,

CCO VARCHAR(256) )

I am using copy command to copy the content of file into the table.
(one.txt)

PR,PRO,HOUSENO,STREET,LOCALITY,CITY,PROVINCE,COUNTRY,ZIP,CON

,,A-24 Siddi vihar apt.,Near Krishna Chowk,New
Sanghvi,Pune,MH,India,411027

In the above data, data for last column is missing.

copy D_2147483927_2147484848_TAB from 'D:/work/one.txt' with delimiter
as ',' quote '"' csv HEADER ;

I get the following error as

ERROR: missing data for column "ccontains"

CONTEXT: COPY d_2147483927_2147484848_tab, line 2: "q,q,A-24 Siddi
vihar apt.,

Near Krishna Chowk,New Sanghvi,Pune,MH,India,411027 "

Can any one please tell me how can I make copy command to ignore the
data missing column ? as the data in file is unknown so it column name
is which is missing is not known in advance.

Thanks

Amar

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Adrian Klaver 2011-01-17 20:46:57 Re: Help needed in skipping column for copy command
Previous Message Marcin Mirosław 2011-01-17 09:23:58 Re: failing to connect to postgresql with php