Re: COPY table to file missing quotation marks - Mailing list pgsql-general

From Steve Crawford
Subject Re: COPY table to file missing quotation marks
Date
Msg-id 510AA1A5.7060702@pinpointresearch.com
Whole thread Raw
In response to Re: COPY table to file missing quotation marks  (Adrian Klaver <adrian.klaver@gmail.com>)
Responses Re: COPY table to file missing quotation marks
List pgsql-general
On 01/31/2013 08:46 AM, Adrian Klaver wrote:
> On 01/31/2013 08:37 AM, Rich Shepard wrote:
>>    I'd like to understand what I'm missing when I COPY a table to a .csv
>> file
>> but the text is not quoted.
>> ...
> http://www.postgresql.org/docs/9.2/interactive/sql-copy.html
>
> CSV Format
>
> ...
> "The values in each record are separated by the DELIMITER character.
> If the value contains the delimiter character, the QUOTE character,
> the NULL string, a carriage return, or line feed character, then the
> whole value is prefixed and suffixed by the QUOTE character, and any
> occurrence within the value of a QUOTE character or the ESCAPE
> character is preceded by the escape character. You can also use
> FORCE_QUOTE to force quotes when outputting non-NULL values in
> specific columns." ...
>
>
> FORCE_QUOTE
> Forces quoting to be used for all non-NULL values in each specified
> column. NULL output is never quoted. If * is specified, non-NULL
> values will be quoted in all columns. This option is allowed only in
> COPY TO, and only when using CSV format.
>

Adrian beat me to answering so I'll just add that different systems
generate and require slightly different CSV formats and though RFC4180
attempts to offer guidance, even that document states:

Definition of the CSV Format:

While there are various specifications and implementations for the CSV
format...there is no formal specification in existence, which allows for
a wide variety of interpretations of CSV files.

Cheers,
Steve




pgsql-general by date:

Previous
From: Rich Shepard
Date:
Subject: Re: COPY table to file missing quotation marks
Next
From: "Little, Douglas"
Date:
Subject: Re: psql question