Re: Importing into Postgres from a csv file

From: Andrew McMillan <Andrew(at)catalyst(dot)net(dot)nz>
To: Jake <ccrasoro(at)home(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Importing into Postgres from a csv file
Date: 2000-08-24 21:20:01
Message-ID: 39A59181.5A0D1F6E@catalyst.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jake wrote:
>
> Does any one know if this is possible, and if so how?
>
> Jake

I have a perl script to do this which you are welcome to if you want
it. I found problems using the:
COPY ... DELIMITER ',' ...
syntax because it didn't (seem to me to) handle data enclosed in quotes,
which might contain quotes and newlines. I.e. something like:

1,"Fred O'Neill said ""Hello!""
""Oh! Hi!"" said Elizabeth.",37,21/3/2000

I had a lot of this sort of stuff in my data, which was exported from a
Microsoft product. A perl script also let me handle nulls more
flexibly.

Regards,
Andrew.
--
_____________________________________________________________________
Andrew McMillan, e-mail: Andrew(at)cat-it(dot)co(dot)nz
Catalyst IT Ltd, PO Box 10-225, Level 22, 105 The Terrace, Wellington
Me: +64 (21) 635 694, Fax: +64 (4) 499 5596, Office: +64 (4) 499 2267

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Franck Martin 2000-08-24 22:50:00 RE: VARCHAR with null
Previous Message Greg Maxwell 2000-08-24 19:54:56 Re: Stupid database use the index!