Using COPY FROM on a subset of the file's column

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Using COPY FROM on a subset of the file's column
Date: 2012-11-11 09:33:09
Message-ID: k7nrc9$7l8$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I'm trying to import a text file into a table using the COPY command.

The text file contains four columns: id, col_1, col_2, col_3 (in that order).
My target table only has id and col_1.

From the documentation I assumed that the following statement

copy foo (id, col_1)
from 'foo.txt'
with (format csv, delimiter ';', header true);

would only import id and col_1, but instead it fails with "ERROR: extra data after last expected column".

Am I missing something, or is this a limitation of the COPY command?

Regards
Thomas

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2012-11-11 10:23:11 Re: Using COPY FROM on a subset of the file's column
Previous Message Craig Ringer 2012-11-11 01:01:02 Re: Running out of memory while making a join