Re: COPY table to file missing quotation marks

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: COPY table to file missing quotation marks
Date: 2013-01-31 18:05:13
Message-ID: 510AB259.9010802@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 01/31/2013 08:53 AM, Rich Shepard wrote:
> On Thu, 31 Jan 2013, Adrian Klaver wrote:
>
>> http://www.postgresql.org/docs/9.2/interactive/sql-copy.html
>
> Adrian,
>
> I've read this.
>
>> 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." ...
>
> So, if the column attribute is text of some flavor I still need to force
> quotes column-by-column?

Or from:

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.

Use FORCE_QUOTE * to quote all columns.

>
> Guess I still need to import the output into a spreadsheet, format each
> text and date column, then write it out again as a .csv file ... or, better
> yet, write a one-line awk program that quotes the appropriate tokens!
> That's
> what I'll do.
>
> Thanks,
>
> Rich
>
>
>

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2013-01-31 18:17:51 Re: COPY table to file missing quotation marks
Previous Message Steve Crawford 2013-01-31 17:14:06 Re: COPY table to file missing quotation marks