Re: CSV file - Using COPY Command - Double-Quotes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Walter <pgsql(at)thejohnsonplace(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: CSV file - Using COPY Command - Double-Quotes
Date: 2005-12-06 21:09:04
Message-ID: 16309.1133903344@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Walter wrote:
>> I have a problem using the copy command on a CSV file.
>>
>> All of the values within the CSV are surrounded with quotation marks. So
>> a null value for a field looks like ""

> It should be ,, for NULL.

> Have you tried WITH NULL AS ''?

Won't help --- that will match a field that is empty and *doesn't* have
quotes.

It seems like the only way to read broken "CSV" files like this would be
to have some option that's sort of the opposite of FORCE NOT NULL ---
that is, force an empty-string data value to be treated as NULL even if
quoted. I'm not in favor of adding that particular frammish, but if
there are enough broken applications out there putting out this sort
of file, we may not have much choice...

Exactly where did this not-really-a-CSV-file come from?

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Walter 2005-12-06 21:15:46 Re: CSV file - Using COPY Command - Double-Quotes
Previous Message Bruce Momjian 2005-12-06 20:17:43 Re: CSV file - Using COPY Command - Double-Quotes