From: nha <lyondif02@free.fr>
To: Chester C Young <chestercyoung@yahoo.com>
Cc: Marcin Stępnicki <mstepnicki@gmail.com>
Cc: PgSQL-sql <pgsql-sql@postgresql.org>
Subject: Re: unused columns in copy
Date: Tue, 21 Jul 2009 02:20:07 +0200
Message-ID: <4A6509B7.7010400@free.fr> (raw)
In-Reply-To: <179149fe0907201559x3e81028aue0b51ba317c2fbbb@mail.gmail.com>
References: <471945.42509.qm@web54306.mail.re2.yahoo.com>
<179149fe0907201559x3e81028aue0b51ba317c2fbbb@mail.gmail.com>
Hello,
Le 21/07/09 0:59, Marcin Stępnicki a écrit :
> On Mon, Jul 20, 2009 at 3:22 PM, chester c young<chestercyoung@yahoo.com> wrote:
>> is there a way for COPY FROM to ignore unused columns in CSV?
>>
>> in other words, if table t1 has columns c1, c2, and if csv has columns c1, c3, c2, could I do something like
>>
>> COPY t1( c1, null, c2 ) FROM 'file.csv'
>
> No, but you can use pgloader which can easily deal with your problem
> and much more. http://pgfoundry.org/projects/pgloader/
>
Depending on PostgreSQL version, copy restrictions may be performed (see
also documentation of PostgreSQL 8.4):
http://www.postgresql.org/docs/8.4/interactive/sql-copy.html
Assuming that a CSV file contains data with column headers c1, c2, and
c3, the following statement would retrieve only columns c1 and c2 from
this file to a table t1:
COPY t1(c1, c2) FROM '/path/to/file.csv';
Regards.
--
nha / Lyon / France.
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: lyondif02@free.fr, chestercyoung@yahoo.com, mstepnicki@gmail.com
Subject: Re: unused columns in copy
In-Reply-To: <4A6509B7.7010400@free.fr>
* 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