Re: Two small questions re/ COPY CSV data into table

Поиск
Список
Период
Сортировка
От Andrew Gierth
Тема Re: Two small questions re/ COPY CSV data into table
Дата
Msg-id 877ea1aby6.fsf@news-spur.riddles.org.uk
обсуждение исходный текст
Ответ на Two small questions re/ COPY CSV data into table  (Matthias Apitz <guru@unixarea.de>)
Ответы Re: Two small questions re/ COPY CSV data into table  (Matthias Apitz <guru@unixarea.de>)
Список pgsql-general
>>>>> "Matthias" == Matthias Apitz <guru@unixarea.de> writes:

 Matthias>    ... WITH DELIMITER '|', FORMAT CSV ;

I think you misread the docs; the new-style syntax would be

COPY ... WITH (DELIMITER '|', FORMAT CSV);

where the parens are not optional. The old-style syntax with no parens
after WITH is what you were using before.

 Matthias> 2. The CSV export is done by some Sybase tool which escapes
 Matthias> the delimiter as '\|', i.e. putting a backslash before the
 Matthias> delimiter. I found no way that COPY understands this
 Matthias> excaping. Any ideas?

That sounds like the file is not actually a CSV - why do you think it
is?

PG accepts two formats (actually 3 if you count binary format which is
rarely used):

TEXT: records are delimited by newlines, columns are delimited by a
delimiter character (default tab), there are no quotation marks, any
newline, backslash, or delimiter in the data must be escaped as a
backslash-sequence (e.g. \n or \012)

CSV: columns may be quoted (in which case delimiters and newlines inside
them are ignored), records are delimited by newlines _outside_ quoted
fields, there are no backslash-sequences or escapes outside of quoted
fields, quote characters inside quoted fields are doubled (though
there's an option to change this).

PG follows the CSV spec at https://www.ietf.org/rfc/rfc4180.txt fairly
closely.

-- 
Andrew (irc:RhodiumToad)



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

Предыдущее
От: Matthias Apitz
Дата:
Сообщение: Two small questions re/ COPY CSV data into table
Следующее
От: Andrew Gierth
Дата:
Сообщение: Re: Research on ?? operators