Re: CSV mode option for pg_dump

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Rod Taylor <pg(at)rbt(dot)ca>
Cc: Bill Bartlett <bbartlett(at)softwareanalytics(dot)com>, "'Andrew Dunstan'" <andrew(at)dunslane(dot)net>, "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "'PG Hackers'" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CSV mode option for pg_dump
Date: 2006-06-13 16:14:48
Message-ID: 448EE478.9010904@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Rod Taylor wrote:
> On Mon, 2006-06-12 at 16:28 -0400, Bill Bartlett wrote:
>> Can't -- the main production database is over at a CoLo site with access
>> only available via SSH, and tightly-restricted SSH at that. Generally
>> one of the developers will SSH over to the server, pull out whatever
>> data is needed into a text file via psql or pg_dump, scp the file(s)
>> back here and send them to the user.
>
> I don't get it. If you can use psql then you already have csv support.
>
> psql -c 'COPY pg_class TO STDOUT WITH CSV' postgres > pg_class.csv

If you data looks like this:

foo barbaz bing

You are o.k. You have three columns, tab delimited.

However if you data looks like this:

foo bar baz bing

You have a problem.

foo is one column
bar and baz are a single column
bing is a single column

How does excel know that bar baz is a single column? It doesn't because
you told it to delimit on tabs and thus you have four columns as far as
Excel is concerned.

An alternative although I don't know what kind of headaches it would
cause is to have a text delimiter as well as a field delimter, e.g;

"foo" "bar baz" "bing"

Sincerely,

Joshua D. Drake

>
>>> -----Original Message-----
>>> From: Joshua D. Drake [mailto:jd(at)commandprompt(dot)com]
>>> Sent: Monday, June 12, 2006 4:15 PM
>>> To: Bill Bartlett
>>> Cc: 'Andrew Dunstan'; 'Tom Lane'; 'PG Hackers'
>>> Subject: Re: [HACKERS] CSV mode option for pg_dump
>>>
>>>
>>> Bill Bartlett wrote:
>>>> Here's me speaking up -- I'd definitely use it! As a
>>> quick way to pull
>>>> data into Excel to do basic reports or analysis, a CSV
>>> format would be
>>>> great.
>>> Why not just use ODBC?
>>>
>>> Joshua D. Drake
>>> --
>>>
>>> === The PostgreSQL Company: Command Prompt, Inc. ===
>>> Sales/Support: +1.503.667.4564 || 24x7/Emergency:
>>> +1.800.492.2240
>>> Providing the most comprehensive PostgreSQL solutions
>>> since 1997
>>> http://www.commandprompt.com/
>>>
>>>
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 1: if posting/reading through Usenet, please send an appropriate
>> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
>> message can get through to the mailing list cleanly
>>

--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message PFC 2006-06-13 16:25:47 Re: CSV mode option for pg_dump
Previous Message Steve Atkins 2006-06-13 16:10:25 Re: CSV mode option for pg_dump