pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@gmail.com>
To: Amar Dhole <adhole@tibco.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Help needed in skipping column for copy command
Date: Mon, 17 Jan 2011 12:46:57 -0800
Message-ID: <4D34AAC1.60002@gmail.com> (raw)
In-Reply-To: <B290BFEC59278744B17A7A3CB14307E90387304A@NA-PA-VBE04.na.tibco.com>
References: <1293747263.1650.7.camel@tony1.localdomain>
	<AANLkTikHcZy-H_iS2KMvvoMLnKDekE=3KBKD9EoBaNa5@mail.gmail.com>
	<6b49785d598885ab7f8c5d3955afd74c.squirrel@mail.prospectiv.com>
	<201012310905.35527.adrian.klaver@gmail.com>
	<B290BFEC59278744B17A7A3CB14307E9038726F0@NA-PA-VBE04.na.tibco.com>
	<AANLkTin3G7wXF0e8_ysFYP6zLYV-7=nt_FPBjzvj_vhe@mail.gmail.com>
	<B290BFEC59278744B17A7A3CB14307E9038728DD@NA-PA-VBE04.na.tibco.com>
	<B290BFEC59278744B17A7A3CB14307E90387304A@NA-PA-VBE04.na.tibco.com>

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



view thread (3+ messages)  latest in thread

Message-ID: <4D34AAC1.60002@gmail.com>
Permalink:  ../4D34AAC1.60002@gmail.com/
Also on:    postgresql.org/message-id/4D34AAC1.60002@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: adrian.klaver@gmail.com, adhole@tibco.com
  Subject: Re: Help needed in skipping column for copy command
  In-Reply-To: <4D34AAC1.60002@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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