pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Nicolas Paris <niparisco@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: COPY error when \. char
Date: Tue, 20 Mar 2018 06:29:06 -0700
Message-ID: <24dee41c-1ce8-e8f6-10eb-ba0e898cc9cd@aklaver.com> (raw)
In-Reply-To: <20180320113204.n3rto7iyekqkzmz4@gmail.com>
References: <20180320113204.n3rto7iyekqkzmz4@gmail.com>

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




view thread (2+ messages)

Message-ID: <24dee41c-1ce8-e8f6-10eb-ba0e898cc9cd@aklaver.com>
Permalink:  ../24dee41c-1ce8-e8f6-10eb-ba0e898cc9cd@aklaver.com/
Also on:    postgresql.org/message-id/24dee41c-1ce8-e8f6-10eb-ba0e898cc9cd@aklaver.com

 · 

reply

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: adrian.klaver@aklaver.com, niparisco@gmail.com
  Subject: Re: COPY error when \. char
  In-Reply-To: <24dee41c-1ce8-e8f6-10eb-ba0e898cc9cd@aklaver.com>
  References: <20180320113204.n3rto7iyekqkzmz4@gmail.com> <24dee41c-1ce8-e8f6-10eb-ba0e898cc9cd@aklaver.com>

* 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