Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eyHKD-0005be-Q1 for pgsql-general@arkaria.postgresql.org; Tue, 20 Mar 2018 13:29:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eyHKC-00024N-Qw for pgsql-general@arkaria.postgresql.org; Tue, 20 Mar 2018 13:29:12 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eyHKC-00024E-7K for pgsql-general@lists.postgresql.org; Tue, 20 Mar 2018 13:29:12 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eyHK9-0006j5-1t for pgsql-general@lists.postgresql.org; Tue, 20 Mar 2018 13:29:11 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id C389A21A97; Tue, 20 Mar 2018 09:29:07 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute6.internal (MEProxy); Tue, 20 Mar 2018 09:29:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=RJ4nLLIU5B3wEQAiU9jap7R3iN9H2 4CAKrUAZB6YRV8=; b=iamUpgAYpI+/5/Q0TaNBe1CiYpTzG+Unlkc3oWU8+mJYQ Y03wmTOOz3m/S+ig5VsVM+sec8WfLhOcmGEW15sfD8+QidM+PJCCzsiuM2Ff8D/S pwbQP1tls86SMqxParoJvz94uyf6k8jnhSxBUi5Ku5zIfnBeirWHRkaqIQThoHh6 M78NcxmBf6WMl2xITtiemKtos7YM8WNmGqvio29PA3muSF/VEf7aCmW/oy+vUz9K ilSdJyxCBSGyt+UuTiGk7S+oxEkHX2kYR5iY9yTHx+z1igmwyAUUQSVN8hHj90Xv NUm8M6pjmeUBYqvU5QXcDMj+Ha07bLxsqwHTprdIw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=RJ4nLL IU5B3wEQAiU9jap7R3iN9H24CAKrUAZB6YRV8=; b=d/jjERc6Kq8jbVh+1QcCyW qJly7wgqW/wxuZFUsX+WVmolPCdzNIh3FCyRKfG2QAmNWOl29uOsQBghmWa4udXH bwi7n3TfhTZdCZKTRKBpPkNzrjPc9sHmggvCO6fOBnxXRckSOrvCYWGcN0fImP3P ew9ZKa/SpOz8eedDyzTEzV4BNd2JYLX4ZwIWyKp8fqggWwoDSfBxOskup+BeOE0q 4s2pQn7zHJj9xWFg8b52W5/TTAuAmI9QvGR5vWQr8UlgXHOmT1bR92bu9/olj8Xv zLuzYenRkTfFWIaw3Z5FtwUiwjnvqtxX5CRCJPSHiNg2F5erWuH9MKcxgD+ZF0lg == X-ME-Sender: Received: from [192.168.1.2] (71-35-123-124.tukw.qwest.net [71.35.123.124]) by mail.messagingengine.com (Postfix) with ESMTPA id 361FB24371; Tue, 20 Mar 2018 09:29:07 -0400 (EDT) Subject: Re: COPY error when \. char To: Nicolas Paris , pgsql-general@lists.postgresql.org References: <20180320113204.n3rto7iyekqkzmz4@gmail.com> From: Adrian Klaver Message-ID: <24dee41c-1ce8-e8f6-10eb-ba0e898cc9cd@aklaver.com> Date: Tue, 20 Mar 2018 06:29:06 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180320113204.n3rto7iyekqkzmz4@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 03/20/2018 04:32 AM, Nicolas Paris wrote: > Hello > > I get an error when loading this kind of csv: > >> test.csv: > "hello ""world""" > "\." > "this > works > " > "this > \. > does > not" > >> table: > create table test (field text); > >> sql: > \copy test (field) from 'test.csv' CSV quote '"' ESCAPE '"'; > ERROR: unterminated CSV quoted field > CONTEXTE : COPY test, line 7: ""this > " > > Apparently, having the \. string in a single line make it break. > Is this normal ? https://www.postgresql.org/docs/10/static/sql-copy.html "Because backslash is not a special character in the CSV format, \., the end-of-data marker, could also appear as a data value. To avoid any misinterpretation, a \. data value appearing as a lone entry on a line is automatically quoted on output, and on input, if quoted, is not interpreted as the end-of-data marker. If you are loading a file created by another application that has a single unquoted column and might have a value of \., you might need to quote that value in the input file." > > Thanks > > -- Adrian Klaver adrian.klaver@aklaver.com