Re: " " around fields with psql

From: Steve Clark <sclark(at)netwolves(dot)com>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>, pgsql-general(at)postgresql(dot)org
Subject: Re: " " around fields with psql
Date: 2012-02-13 20:43:34
Message-ID: 4F3975F6.4090702@netwolves.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 02/13/2012 02:13 PM, Merlin Moncure wrote:
> On Sat, Feb 11, 2012 at 2:03 AM, Jasen Betts<jasen(at)xnet(dot)co(dot)nz> wrote:
>> On 2012-02-10, Steve Clark<sclark(at)netwolves(dot)com> wrote:
>>
>>> Is there a way with psql to get column output to be
>>> "data1","data2",...,"datan"
>> assuming you are trying to be compatible with CSV:
>>
>> copy ( your_query_here ) to stdout with csv header ;
> yeah -- that's the best way if you want actual csv, from psql you'd
> probably want to do \copy:
> postgres=# \copy (select 1, '"', 'ab,c') to stdout csv header;
> ?column?,?column?,?column?
> 1,"""","ab,c"
>
> note that per csv rules columns are only required to be quoted to
> protect from unambiguous parsing. also, double quotes in your field
> will be escaped.
>
> merlin
>
Thanks to all that replied.

--
Stephen Clark
*NetWolves*
Director of Technology
Phone: 813-579-3200
Fax: 813-882-0209
Email: steve(dot)clark(at)netwolves(dot)com
http://www.netwolves.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Eliot Gable 2012-02-13 22:30:20 What is the life of a postgres back end process?
Previous Message Merlin Moncure 2012-02-13 19:13:37 Re: " " around fields with psql