469,929 Members | 1,771 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,929 developers. It's quick & easy.

Export CSV from psql

Hi,
is there a way to display the table in CSV format or write a query in
csv to a file ?

Alex

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #1
1 10896
I use the standard pipe signs as delimiters, comma's are a pretty silly
delimiter if you ask me. Try putting this at the top of your psql query

-- \a toggle between unaligned and aligned output mode
-- \t show only rows (currently off)
-- \o [FILE] send all query results to file or |pipe
\a
\t
\o /tmp/outputfile.txt
select ......
\o

Don't know if this helps you, or if you really need CSV. Someone probably
has written a CSV export I 'spose.

Best of luck.

Craig
On Thu, 20 Nov 2003, Alex wrote:
Hi,
is there a way to display the table in CSV format or write a query in
csv to a file ?

Alex

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Daniel Schuchardt | last post: by
1 post views Thread by Alex | last post: by
7 posts views Thread by Willem Herremans | last post: by
4 posts views Thread by Brendan Jurd | last post: by
15 posts views Thread by Dino Vliet | last post: by
1 post views Thread by Josué Maldonado | last post: by
2 posts views Thread by Russ Brown | last post: by
33 posts views Thread by John Sidney-Woollett | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.