Help needed in skipping column for copy command - Mailing list pgsql-sql

From Amar Dhole
Subject Help needed in skipping column for copy command
Date
Msg-id B290BFEC59278744B17A7A3CB14307E90387304A@NA-PA-VBE04.na.tibco.com
Whole thread Raw
In response to Re: help needs in converting db2 function in postgresql.  ("Amar Dhole" <adhole@tibco.com>)
Responses Re: Help needed in skipping column for copy command
Re: Help needed in skipping column for copy command
List 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

 

pgsql-sql by date:

Previous
From: Marcin Mirosław
Date:
Subject: Re: failing to connect to postgresql with php
Next
From: Adrian Klaver
Date:
Subject: Re: Help needed in skipping column for copy command