[clue-tech] postgres CSV export with headers

Dave Price kinaole at gmail.com
Wed Dec 13 13:25:05 MST 2006


Cluefull Ones,

I have looked and looked, and cannot find an answer to a simple challenge.

I want to export a CSV file from postgres, but I would like to include
the collumn names as the top row of the file to make it easier for
folks who ope the file in 'a spreadsheet of their choice' to
undersatand the data.

The CSV export is pretty simple, if I am willing to add the headers by hand:

psql foo -c "begin; create table blah as select * from my_summary
order by provider, period_end; copy  blah to '/tmp/blah.csv' CSV;
rollback "


I cannot find a switch or other option that I can switch on to achieve
this.  Any hints.

-- 
aloha (and thanks in advance),
dave



More information about the clue-tech mailing list