Re: import CSV file

From: T E Schmitz <mailreg(at)numerixtechnology(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: import CSV file
Date: 2007-03-13 23:44:02
Message-ID: 45F73742.2080505@numerixtechnology.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

D'Arcy J.M. Cain wrote:
> On Tue, 13 Mar 2007 20:38:33 +0000
> T E Schmitz <mailreg(at)numerixtechnology(dot)de> 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message T E Schmitz 2007-03-13 23:48:43 Re: import CSV file
Previous Message Jure Kodzoman 2007-03-13 22:35:51 Re: import CSV file