Re: COPY error when \. char

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: COPY error when \. char
Дата
Msg-id 24dee41c-1ce8-e8f6-10eb-ba0e898cc9cd@aklaver.com
обсуждение исходный текст
Ответ на COPY error when \. char  (Nicolas Paris <niparisco@gmail.com>)
Список pgsql-general
On 03/20/2018 04:32 AM, Nicolas Paris wrote:
> Hello
> 
> I get an error when loading this kind of csv:
> 
>> test.csv:
> "hello ""world"""
> "\."
> "this
> works
> "
> "this
> \.
> does
> not"
> 
>> table:
> create table test (field text);
> 
>> sql:
> \copy test (field) from 'test.csv' CSV  quote '"' ESCAPE '"';
> ERROR:  unterminated CSV quoted field
> CONTEXTE : COPY test, line 7: ""this
> "
> 
> Apparently, having the \.  string in a single line make it break.
> Is this normal ?

https://www.postgresql.org/docs/10/static/sql-copy.html
"Because backslash is not a special character in the CSV format, \., the 
end-of-data marker, could also appear as a data value. To avoid any 
misinterpretation, a \. data value appearing as a lone entry on a line 
is automatically quoted on output, and on input, if quoted, is not 
interpreted as the end-of-data marker. If you are loading a file created 
by another application that has a single unquoted column and might have 
a value of \., you might need to quote that value in the input file."

> 
> Thanks
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com


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

Предыдущее
От: HORDER Phil
Дата:
Сообщение: Foreign Key locking / deadlock issue.
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Foreign Key locking / deadlock issue.