pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Help needed in skipping column for copy command
3+ messages / 3 participants
[nested] [flat]

* Help needed in skipping column for copy command
@ 2011-01-17 13:59  Amar Dhole <adhole@tibco.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Amar Dhole @ 2011-01-17 13:59 UTC (permalink / raw)
  To: pgsql-sql; +Cc: 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 

 

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Help needed in skipping column for copy command
@ 2011-01-17 20:46  Adrian Klaver <adrian.klaver@gmail.com>
  parent: Amar Dhole <adhole@tibco.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Adrian Klaver @ 2011-01-17 20:46 UTC (permalink / raw)
  To: Amar Dhole <adhole@tibco.com>; +Cc: pgsql-sql

On 01/17/2011 05:59 AM, Amar Dhole wrote:
> 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.

Looks like two columns missing. I see 10 headers and 8 data values 
unless that is a cut and paste issue.

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

Where does ccontains from? I am not seeing it in the table or the text file.

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

You can specify a column list to COPY. See here:
http://www.postgresql.org/docs/9.0/interactive/sql-copy.html

>
> Thanks
>
> Amar
>


-- 
Adrian Klaver
adrian.klaver@gmail.com



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Help needed in skipping column for copy command
@ 2011-01-17 21:14  Russell Galyon <russellgalyon@gmail.com>
  parent: Amar Dhole <adhole@tibco.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Russell Galyon @ 2011-01-17 21:14 UTC (permalink / raw)
  To: Amar Dhole <adhole@tibco.com>; +Cc: pgsql-sql

COPY  D_2147483927_2147484848_TAB
    (
        CP
        , CPR
        , CHOUSENO
        , CSTREET
        , CLOCALITY
        , CCITY
        , CPROVINCE
        , CCOUNTRY
        , CZIP
    )
FROM 'one.txt'
WITH DELIMITER ',' QUOTE '"' csv HEADER;



On Mon, Jan 17, 2011 at 7:59 AM, Amar Dhole <adhole@tibco.com> wrote:

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

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2011-01-17 21:14 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-01-17 13:59 Help needed in skipping column for copy command Amar Dhole <adhole@tibco.com>
2011-01-17 20:46 ` Adrian Klaver <adrian.klaver@gmail.com>
2011-01-17 21:14 ` Russell Galyon <russellgalyon@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox