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

From Thomas Kellerer
Subject Re: COPY table_name (single_column) FROM 'iso-8859-1.txt' DELIMITER E'\n'
Date
Msg-id 9d44d69d-0bdc-4974-e598-1c9b210fd132@gmx.net
Whole thread Raw
In response to COPY table_name (single_column) FROM 'iso-8859-1.txt' DELIMITER E'\n'  ("Joel Jacobson" <joel@compiler.org>)
List 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 by date:

Previous
From: "Joel Jacobson"
Date:
Subject: Re: COPY table_name (single_column) FROM 'iso-8859-1.txt' DELIMITER E'\n'
Next
From: "Joel Jacobson"
Date:
Subject: Re: COPY table_name (single_column) FROM 'iso-8859-1.txt' DELIMITER E'\n'