Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 7A79B9FB5A5 for ; Tue, 13 Mar 2007 20:44:22 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 56675-07 for ; Tue, 13 Mar 2007 20:44:10 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from zebedee.cranntara.net (zebedee.cranntara.net [91.186.7.79]) by postgresql.org (Postfix) with ESMTP id 344359FB31E for ; Tue, 13 Mar 2007 20:44:15 -0300 (ADT) Received: from dial-dynamic-62-69-36-139.surfdial.murphx.net ([62.69.36.139] helo=bolek.coachhouse) by zebedee.cranntara.net with esmtpsa (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.62) (envelope-from ) id 1HRGf5-00027O-K2 for pgsql-sql@postgresql.org; Tue, 13 Mar 2007 23:44:12 +0000 Received: from [192.168.0.32] (helo=[192.168.0.32]) by bolek.coachhouse with esmtp (Exim 4.50) id 1HRGew-0003o0-V5 for pgsql-sql@postgresql.org; Tue, 13 Mar 2007 23:44:02 +0000 Message-ID: <45F73742.2080505@numerixtechnology.de> Date: Tue, 13 Mar 2007 23:44:02 +0000 From: T E Schmitz Reply-To: mailreg@numerixtechnology.de User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: import CSV file References: <45F70BC9.801@numerixtechnology.de> <20070313182740.ef40e742.darcy@druid.net> In-Reply-To: <20070313182740.ef40e742.darcy@druid.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/186 X-Sequence-Number: 27824 D'Arcy J.M. Cain wrote: > On Tue, 13 Mar 2007 20:38:33 +0000 > T E Schmitz wrote: > >>I am trying to batch-load a tab-separated CSV file: >> >>psql -h lolek -U tes -d stockmarket -c "copy history from >>'/tmp/FTSE.csv' CSV"; >> >>ERROR: could not open file "/tmp/FTSE.csv" for reading: No such file or >>directory >> >>The file exists. Do I need to escape the quotes? > > > From the "-h" option I assume that the server is not on the local > machine and hence the file is not available to the server. You need to > do something like this: > > psql -h lolek -U tes -d stockmarket -c "copy history from STDIN CSV" < /tmp/FTSE.csv > This is pretty ingenious! Just a few minor problems: - how does COPY know which column is which? - how do I specify DELIMITER as TAB? -- Regards/Gruß, Tarlika Elisabeth Schmitz