Skip site navigation (1) Skip section navigation (2)

Re: Importing CSV file

From: John Poltorak <jp(at)eyup(dot)org>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Importing CSV file
Date: 2001-01-15 18:19:39
Message-ID: 20010115181939.P85@eyup.org (view raw or flat)
Thread:
Lists: pgsql-novice
On Tue, Jan 16, 2001 at 07:08:50AM +1300, Andrew McMillan wrote:
> John Poltorak wrote:
> >
> > Is there a simple way to import a CSV file into a Postgres database?
>
> If it is a simple CSV file then you should be able to manage with the
> COPY command, using appropriate values for DELIMITERS.

Thanks, I have managed to stumble across the COPY FROM command now.

> If your CSV file has text quoted, and which includes line breaks within
> fields, then you need to get more complex.

I'm only trying simple stuff to begin with.

I have found some problems in attempting to copy files, and it appears
due to line termination on OS/2... The last field is rejected normally,
but if I convert lines from CRLF to LF, then it works.

> I have a perl script you can use in this case, if you want.

I'll bear that in mind thanks.

> Regards,
>                                       Andrew.
> --
> _____________________________________________________________________
>            Andrew McMillan, e-mail: Andrew(at)catalyst(dot)net(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

--
John


In response to

pgsql-novice by date

Next:From: matDate: 2001-01-15 19:58:23
Subject: problem with pg_dump
Previous:From: Andrew McMillanDate: 2001-01-15 18:08:50
Subject: Re: Importing CSV file

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group