Re: generate CSV with Copy+Quotes - Postgres 9.2

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Patrick B <patrickbakerbr(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: generate CSV with Copy+Quotes - Postgres 9.2
Date: 2016-09-21 13:33:02
Message-ID: ec6a257c-0bfb-d23a-806a-e04dfc36c7ed@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 09/21/2016 02:23 AM, Patrick B wrote:
> Hi guys,
>
> I'm exporting some data for testing purpose.
>
> COPY (SELECT
> name_first
> name_last,
> email,
> company
> FROM
> clients
> )
> TO '/var/lib/pgsql/test1.csv' DELIMITER ',' csv HEADER QUOTE '"';
>
>
>
> cat /var/lib/pgsql/test1.csv
>
> "","",hiddenemail(at)hotmail(dot)com
> <mailto:hiddenemail(at)hotmail(dot)com>,"",John Wayne
>

In your COPY you have fields and in the CSV file you have five.
Are you looking at the correct file?

>
> See how the email and the company aren't into two "?

Have no idea what you are trying to say.

hiddenemail(at)hotmail(dot)com looks like a correct email to me.

Maybe if you show what the data is in the table?

>
> *What I need is:*
>
> "","","hiddenemail(at)hotmail(dot)com
> <mailto:hiddenemail(at)hotmail(dot)com>","","John Wayne"
>
>
> I thought that by putting QUOTE the COPY would do that?
>
> Is there any way I can put the " into those fields?
>
> Cheers
>
> Patrick
>

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Melvin Davidson 2016-09-21 15:00:11 Re: generate CSV with Copy+Quotes - Postgres 9.2
Previous Message kbrannen 2016-09-21 12:39:30 Re: overwrite column data select - Postgres 9.2