Received: from mail.postgresql.org (webmail.postgresql.org [216.126.85.28]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f22Dhnx09775 for ; Fri, 2 Mar 2001 08:43:50 -0500 (EST) (envelope-from pgsql-sql-owner@postgresql.org) Received: from news.tht.net (news.hub.org [216.126.91.242]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f21Kxmx91376 for ; Thu, 1 Mar 2001 15:59:48 -0500 (EST) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f21Kjcd81972 for pgsql-sql@postgresql.org; Thu, 1 Mar 2001 15:45:38 -0500 (EST) (envelope-from news) From: Terry Fielder X-Newsgroups: comp.databases.postgresql.sql Subject: SQL copy from csv with explicit field ordering Date: Thu, 01 Mar 2001 15:46:06 -0500 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 38 Message-ID: <3A9EB50E.C2770BEA@greatgulfhomes.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: scrappy@hub.org X-Mailer: Mozilla 4.61 [en] (Win98; I) X-Accept-Language: en To: pgsql-sql@postgresql.org X-Archive-Number: 200103/21 X-Sequence-Number: 1663 I guess this is really a SQL question: I have a csv that I want to import, but the csv has different column ordering. I have tried putting the column names in the first row, but then the copy command fails on field which is data type (eg it is seeing the cells in first row as data, not header info). ggtest=> copy ap_trans from '/var/dbase/ap_trans.csv' using delimiters ','; ERROR: pg_atoi: error in "id": can't parse "id" The help indicates: ggtest=> \h copy Command: copy Description: copy data to and from a table Syntax: COPY [BINARY] class_name [WITH OIDS] TO|FROM filename|STDIN|STDOUT [USING DELIMITERS 'delim']; I have tried WITH OIDS but with same results. Is there somewhere that I can either enable the first line of CSV as header names OR Can I explicitly define my import field ordering from within the select statement? Thanks Terry Fielder terry@greatgulfhomes.com