Re: Using COPY

From: "Joel Burton" <joel(at)joelburton(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <joe(at)jwebmedia(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Using COPY
Date: 2002-05-14 16:24:48
Message-ID: JGEPJNMCKODMDHGOBKDNEEDLCOAA.joel@joelburton.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Tom Lane
> Sent: Tuesday, May 14, 2002 11:04 AM
> To: joe(at)jwebmedia(dot)com
> Cc: pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] Using COPY
>
>
> Joseph Koenig <joe(at)jwebmedia(dot)com> writes:
> > We're converting a db from Access to PostgreSQL for a client - I need to
> > export all of his data into postgres on Linux - I'm trying to use the
> > COPY command, however, his comment fields have line breaks in them which
> > causes the copy to throw a parse error at that line. I'm sure others
> > have run into this - is there an easy way to avoid this? Thanks,
>
> You'll need to transform the linebreaks that should be data into \n
> (backslash-n) or \LF (backslash-newline) sequences.

This would be the best way. It arrives perfectly in PG.

Or, if that's tricky for you to do w/the conversion/output tools you have at
your disposal, turn the linebreaks into some unusual marker ("@@~@@") using
any tool (emacs, perl, even Microsoft Word will do), pull the data in using
COPY, and once in pgsql, you can fix this with a query.

If you're going to use Access as a front-end onto the data, there's a
document with some help for this setup at
http://joelburton.com/resources/pgaccess.

HTH.

- J.

Joel BURTON | joel(at)joelburton(dot)com | joelburton.com | aim: wjoelburton
Knowledge Management & Technology Consultant

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Pfau 2002-05-14 16:36:51 Re: Question about setval() function
Previous Message Jeff Wright 2002-05-14 16:22:11 foreign keys not working