Re: Exporting postgres query to CSV

From: SCassidy(at)overlandstorage(dot)com
To: Ryan Suarez <ryan(dot)suarez(at)sheridanc(dot)on(dot)ca>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Exporting postgres query to CSV
Date: 2006-05-09 16:23:44
Message-ID: OFE0CA6758.2E60DA2F-ON88257169.0059E9BA-88257169.005A1042@overlandstorage.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

A word of advice: if there is any chance that a column (e.g. text) contains
an embedded newline, you will be much better off outputting the data in
simple xml, instead of CSV. This works very well with Excel for import. I
just did a simple program for this recently.

Susan


Ryan Suarez
<ryan(dot)suarez(at)sheridanc(dot) To: pgsql-general(at)postgresql(dot)org
on.ca> cc:
Sent by: Subject: [GENERAL] Exporting postgres query to CSV

|-------------------|
pgsql-general-owner(at)pos | [ ] Expand Groups |
tgresql.org |-------------------|


05/09/2006 07:58
AM

Greetings,

I am running postgres 7.4.7 on debian sarge.

I need to run an SQL query and store the results in a file. The format
needs to be comma separated values (CSV), so I can import this later in
Excel.

Any ideas on how to accomplish this?

much appreciated,
Ryan

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

----------------------------------------------------------------------------------------------
Simply protected storage solutions ensure that your information is
automatically safe, readily available and always there, visit us at http://www.overlandstorage.com
----------------------------------------------------------------------------------------------

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-05-09 16:25:11 Re: pg_dump and grants to PUBLIC
Previous Message Guido Neitzer 2006-05-09 16:20:50 Re: What is your favorite front end for user interaction