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 1hYCk4-0004MY-7R for pgsql-general@arkaria.postgresql.org; Tue, 04 Jun 2019 16:56:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hYCk3-00074U-3f for pgsql-general@arkaria.postgresql.org; Tue, 04 Jun 2019 16:56:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hYCk2-00074N-NV for pgsql-general@lists.postgresql.org; Tue, 04 Jun 2019 16:56:54 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hYCk0-00053W-Bv for pgsql-general@postgresql.org; Tue, 04 Jun 2019 16:56:53 +0000 Received: from [192.168.127.1] (port=31943 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1hYCjx-0005RL-UQ; Tue, 04 Jun 2019 16:56:49 +0000 Received: from [127.0.0.1] (port=26308 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1hYCjx-00024K-9e; Tue, 04 Jun 2019 16:56:49 +0000 From: Andrew Gierth To: Matthias Apitz Cc: Postgres general Subject: Re: Two small questions re/ COPY CSV data into table In-Reply-To: <20190604162650.GA15928@sh4-5.1blu.de> (Matthias Apitz's message of "Tue, 4 Jun 2019 18:26:50 +0200") Message-ID: <87blzd8fdq.fsf@news-spur.riddles.org.uk> References: <20190604100247.GA2800@c720-r342378> <877ea1aby6.fsf@news-spur.riddles.org.uk> <20190604150318.GA13915@sh4-5.1blu.de> <87sgsp8ikd.fsf@news-spur.riddles.org.uk> <20190604162650.GA15928@sh4-5.1blu.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Tue, 04 Jun 2019 17:56:49 +0100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Matthias" == Matthias Apitz writes: Matthias> sed 's/|/\v/g' < table-from-Sybase | sed 's/\\\v/|/g' > table-for-copy >> What on earth is this supposed to achieve? Matthias> It first translates any char '|' to vtab and then any '\vtab' Matthias> (i.e. a backslash followed by a vtab) back to the char | Matthias> The new DELIMITER for PG is then vtab and the | is just a char in the Matthias> data (in the example above a pipe of two UNIX cmd). Yes, but why? If you use COPY ... WITH DELIMITER '|' (i.e. text mode, not CSV mode) then the \| is accepted as being a literal | and the unescaped | is treated as a delimiter. What is the point of the substitutions? -- Andrew (irc:RhodiumToad)