Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hYAyD-0001wC-VL for pgsql-general@arkaria.postgresql.org; Tue, 04 Jun 2019 15:03:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hYAyC-0008S2-QG for pgsql-general@arkaria.postgresql.org; Tue, 04 Jun 2019 15:03:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hYAyC-0008Rv-G9 for pgsql-general@lists.postgresql.org; Tue, 04 Jun 2019 15:03:24 +0000 Received: from smh-06.1blu.de ([178.254.0.206]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hYAy8-0003ug-U2 for pgsql-general@postgresql.org; Tue, 04 Jun 2019 15:03:23 +0000 Received: from [172.16.29.5] (helo=sh4-5.1blu.de) by smh-06.1blu.de with esmtp (Exim 4.86_2) (envelope-from ) id 1hYAy6-0002Vj-8s; Tue, 04 Jun 2019 17:03:18 +0200 Received: from ftp51246-2575596 by sh4-5.1blu.de with local (Exim 4.86_2) (envelope-from ) id 1hYAy6-00046x-6d; Tue, 04 Jun 2019 17:03:18 +0200 Date: Tue, 4 Jun 2019 17:03:18 +0200 From: Matthias Apitz To: Andrew Gierth Cc: Matthias Apitz , Postgres general Subject: Re: Two small questions re/ COPY CSV data into table Message-ID: <20190604150318.GA13915@sh4-5.1blu.de> Reply-To: Matthias Apitz References: <20190604100247.GA2800@c720-r342378> <877ea1aby6.fsf@news-spur.riddles.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <877ea1aby6.fsf@news-spur.riddles.org.uk> X-Operating-System: FreeBSD 12.0-CURRENT r314251 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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!