From: | Thomas Kellerer <shammat(at)gmx(dot)net> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: COPY table_name (single_column) FROM 'unknown.txt' DELIMITER E'\n' |
Date: | 2021-05-06 06:10:20 |
Message-ID: | 9d44d69d-0bdc-4974-e598-1c9b210fd132@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Joel Jacobson | 2021-05-06 06:13:48 | Re: COPY table_name (single_column) FROM 'unknown.txt' DELIMITER E'\n' |
Previous Message | Joel Jacobson | 2021-05-06 05:52:11 | Re: COPY table_name (single_column) FROM 'unknown.txt' DELIMITER E'\n' |