Re: Two small questions re/ COPY CSV data into table

From: Matthias Apitz <guru(at)unixarea(dot)de>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: Matthias Apitz <guru(at)unixarea(dot)de>, Postgres general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Two small questions re/ COPY CSV data into table
Date: 2019-06-04 15:03:18
Message-ID: 20190604150318.GA13915@sh4-5.1blu.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)unixarea(dot)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!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Gierth 2019-06-04 15:41:47 Re: Two small questions re/ COPY CSV data into table
Previous Message Jeremy Finzel 2019-06-04 13:37:22 Re: Questions about btree_gin vs btree_gist for low cardinality columns