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                                          
                                                          
                      <[EMAIL PROTECTED]        To:       
pgsql-general@postgresql.org                                               
                      on.ca>                         cc:                        
                                                          
                           Sent by:                  Subject:  [GENERAL] 
Exporting postgres query to CSV                                  
                                                                                
                                                          
                                                      |-------------------|     
                                                          
                      [EMAIL PROTECTED]         | [ ] 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
----------------------------------------------------------------------------------------------


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

Reply via email to