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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: CSV file - Using COPY Command - Double-Quotes
Дата
Msg-id 16309.1133903344@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: CSV file - Using COPY Command - Double-Quotes  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-novice
Bruce Momjian <pgman@candle.pha.pa.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

В списке pgsql-novice по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: CSV file - Using COPY Command - Double-Quotes
Следующее
От: Walter
Дата:
Сообщение: Re: CSV file - Using COPY Command - Double-Quotes