Thread: COPY FROM file with zero-delimited fields

COPY FROM file with zero-delimited fields

From
eugene.mindrov@gmail.com
Date:
Hi all,
I wonder if there's a way to use COPY FROM command when dealing with a
data file containing records whose fields are delimited with zero-
byte? Or I'd better change the delimiter? :)


Re: COPY FROM file with zero-delimited fields

From
"Merlin Moncure"
Date:
On 11 Apr 2007 00:25:50 -0700, eugene.mindrov@gmail.com
<eugene.mindrov@gmail.com> wrote:
> Hi all,
> I wonder if there's a way to use COPY FROM command when dealing with a
> data file containing records whose fields are delimited with zero-
> byte? Or I'd better change the delimiter? :)

you can always run it through tr or similar tools first.

merlin

Re: COPY FROM file with zero-delimited fields

From
eugene.mindrov@gmail.com
Date:
On Apr 11, 7:42 pm, mmonc...@gmail.com ("Merlin Moncure") wrote:
> On 11 Apr 2007 00:25:50 -0700, eugene.mind...@gmail.com
>
> <eugene.mind...@gmail.com> wrote:
> > Hi all,
> > I wonder if there's a way to use COPY FROM command when dealing with a
> > data file containing records whose fields are delimited with zero-
> > byte? Or I'd better change the delimiter? :)
>
> you can always run it through tr or similar tools first.
>
> merlin
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org/

Yes, sure, I know that, but the matter is - the fields are mostly
textual ones, and can hold just about any text, so it's hard to choose
a right delimiter for fields, you know ;) I though I'd eliminate the
problem by using zero-byte for a field delimiter, but apparently COPY
FROM accepts only "printable" symbols as delimiters...
Another solution would be to escape potential delimiter everywhere in
the text fields, but that also requires using external tools... I had
a hope that COPY FROM can be persuaded to use some non-printable
character in its WITH DELIMITER clause, but apparently this is not the
case...