Re: COPY table_name (single_column) FROM 'iso-8859-1.txt' DELIMITER E'\n'

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: COPY table_name (single_column) FROM 'iso-8859-1.txt' DELIMITER E'\n'
Дата
Msg-id 9d44d69d-0bdc-4974-e598-1c9b210fd132@gmx.net
обсуждение исходный текст
Ответ на COPY table_name (single_column) FROM 'iso-8859-1.txt' DELIMITER E'\n'  ("Joel Jacobson" <joel@compiler.org>)
Список pgsql-hackers
Joel Jacobson schrieb am 05.05.2021 um 17:30:
> Could it be an idea to exploit the fact that DELIMITER E'\n' is currently an error?
>
>     ERROR:  COPY delimiter cannot be newline or carriage return
>
> That is, to change E'\n' to be a valid delimiter, which would simply read each line
> delimited by newlines, as a single column.
>
> The hack I'm currently abusing is to find some one-byte character that is not present anywhere in the text file,
> and then to use that character as a delimiter. This doesn't work when needing to deal with a text file
> which content is unknown at the time when writing the code though, so it's mostly useful for throwaway one-off
queries.

What about

    delimiter E'\1'

The probability that a file contains the ASCII "character" 1 seems rather low.

Thomas





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

Предыдущее
От: "Joel Jacobson"
Дата:
Сообщение: Re: COPY table_name (single_column) FROM 'iso-8859-1.txt' DELIMITER E'\n'
Следующее
От: "Joel Jacobson"
Дата:
Сообщение: Re: COPY table_name (single_column) FROM 'iso-8859-1.txt' DELIMITER E'\n'