Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id AC91E9FB279 for ; Tue, 21 Nov 2006 18:38:49 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 66330-01 for ; Tue, 21 Nov 2006 18:38:46 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web31801.mail.mud.yahoo.com (web31801.mail.mud.yahoo.com [68.142.207.64]) by postgresql.org (Postfix) with SMTP id 5EBD29FB277 for ; Tue, 21 Nov 2006 18:38:45 -0400 (AST) Received: (qmail 21660 invoked by uid 60001); 21 Nov 2006 22:38:43 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=VpdKJPOf5GJf4I2xm46lIwxq9s8OwkVt6oRxPXoESQWeHP/T2/Mo61gZpR5oskr/jHq7lyuGoswf0SDIq7Nxc71Xxv31+MLGXAgvWMdnvDIONX4c+kkV4inGqsiIj11r16/cPY1aMoqNcfay/xNYxQcoCWHIImhiQw7W5+b3YBo= ; X-YMail-OSG: IGaGp_wVM1m4BOovRdyVtaafAFJGT1VNo2sU9TYGYWZBtIulpu5z5dHRxfDrGlmhrWtjEda16d.eNBfss_OSlHWC9fvtQXxGuKbRRgKQSlgzrgZkkOYWA0.dW9grYP8pPKIssjYiymSRzX9DJd1vmWzbBA1lXOyqKYoQzCy.8k2gFT8MT1BTAyHjY1U8 Received: from [12.177.97.50] by web31801.mail.mud.yahoo.com via HTTP; Tue, 21 Nov 2006 14:38:43 PST Date: Tue, 21 Nov 2006 14:38:43 -0800 (PST) From: Richard Broersma Jr Subject: Re: "Copy from" omit source columns? To: Steve Midgley , pgsql-sql@postgresql.org In-Reply-To: <20061121221911.C10D09FB26E@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <737014.20604.qm@web31801.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.194 tagged_above=0 required=5 tests=AWL, BAYES_00, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS X-Spam-Level: X-Archive-Number: 200611/225 X-Sequence-Number: 26877 > (I already fear the answer to my question is "no..") :) > I am using the 'COPY FROM' SQL command (not psql \copy) to move data > into a table from a CSV file. The source data are suitable for import > EXCEPT there are extraneous columns of data in the source file. In > essence, my table schema is: > id, col1, col2, col4 > My source file schema is: > col1,col2,col3,col4 > I'm curious if there is any way to tell "COPY" to ignore the third > column of data? Basically I'd like to write something along the lines > of: > copy import (col1,col2,\n,col4) > from 'c:/dev/import/source/test.csv' > with CSV HEADER > Note "\n" would indicate there there is a column in the source that > should simply be ignored during the import. Of course, I tried this > syntax and it didn't work. Perhaps there is another way of indicating > that there is a "null column" in the source file that should be skipped > during import? > Any assistance in solving this problem (without having to change the > source file) would be greatly appreciated. If I have to change the > source file, I will, but it would greatly simplify things if I didn't > have to.. I am not to familiar with using copy, so I do not know the eligant solution that you are looking for. But the brute-force method would be to: 1) push all your data into a temp table 2) validate it 3) push the data of enterest into the destination table. Regards, Richard Broersma Jr.