Re: Quoted NULLs with COPY FROM

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: George Pavlov <gpavlov(at)mynewplace(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Quoted NULLs with COPY FROM
Date: 2006-01-24 02:56:36
Message-ID: 200601240256.k0O2uaP23749@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

George Pavlov wrote:
> I need to load CSV files that have quotes in data fields that I want to
> map to NULLs in the destination table. So if I see ...,"",... that needs
> to be mapped to a NULL (in an INTEGER field in this particular case).
> Are there any COPY command options that can do that? It seems that PgSQL
> COPY expects the NULL to be always unquoted. There is an option (FORCE
> NOT NULL) for doing the opposite. How do I specify that the NULLs are
> quoted? I am on 8.0.5.

Did you try NULL AS ''?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2006-01-24 02:58:35 Re: Does this look ethical to you?
Previous Message Tony Caduto 2006-01-24 02:52:36 Does this look ethical to you?