Re: Two small questions re/ COPY CSV data into table - Mailing list pgsql-general

From Matthias Apitz
Subject Re: Two small questions re/ COPY CSV data into table
Date
Msg-id 20190604150318.GA13915@sh4-5.1blu.de
Whole thread Raw
In response to Re: Two small questions re/ COPY CSV data into table  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Responses Re: Two small questions re/ COPY CSV data into table
List pgsql-general
El día Tuesday, June 04, 2019 a las 11:32:45AM +0100, Andrew Gierth escribió:

>  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?
> 
> ...

Well, it's not strictly CSV, but it is what the Sybase tool produces. The
delimiter is set to '|' and a data example line looks like:

0|1| cat $1 \| lpr -Pprinter |3|4

I do load this now with COPY in mode TEXT and modify the data before
with:

 sed 's/|/\v/g' < table-from-Sybase  | sed 's/\\\v/|/g' > table-for-copy

Works fine.

    matthias

-- 
Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub
May, 9: Спаси́бо освободители! Thank you very much, Russian liberators!



pgsql-general by date:

Previous
From: Jeremy Finzel
Date:
Subject: Re: Questions about btree_gin vs btree_gist for low cardinality columns
Next
From: Andrew Gierth
Date:
Subject: Re: Two small questions re/ COPY CSV data into table