From: Matthias Apitz <guru@unixarea.de>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: Matthias Apitz <guru@unixarea.de>
Cc: Postgres general <pgsql-general@postgresql.org>
Subject: Re: Two small questions re/ COPY CSV data into table
Date: Tue, 4 Jun 2019 17:03:18 +0200
Message-ID: <20190604150318.GA13915@sh4-5.1blu.de> (raw)
In-Reply-To: <877ea1aby6.fsf@news-spur.riddles.org.uk>
References: <20190604100247.GA2800@c720-r342378>
<877ea1aby6.fsf@news-spur.riddles.org.uk>
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!
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: guru@unixarea.de, andrew@tao11.riddles.org.uk
Subject: Re: Two small questions re/ COPY CSV data into table
In-Reply-To: <20190604150318.GA13915@sh4-5.1blu.de>
References: <20190604100247.GA2800@c720-r342378> <877ea1aby6.fsf@news-spur.riddles.org.uk> <20190604150318.GA13915@sh4-5.1blu.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox