Re: CSV mode option for pg_dump - Mailing list pgsql-hackers

From Joshua D. Drake
Subject Re: CSV mode option for pg_dump
Date
Msg-id 448EE478.9010904@commandprompt.com
Whole thread Raw
In response to Re: CSV mode option for pg_dump  (Rod Taylor <pg@rbt.ca>)
Responses Re: CSV mode option for pg_dump  (Martijn van Oosterhout <kleptog@svana.org>)
List 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@commandprompt.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@postgresql.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/




pgsql-hackers by date:

Previous
From: Steve Atkins
Date:
Subject: Re: CSV mode option for pg_dump
Next
From: PFC
Date:
Subject: Re: CSV mode option for pg_dump