I'm having problem exporting my PostgreSQL output from a shell to a csv file.
My SQL script is called
psql congress -af script.sql &> filename.csv
Copy (Select * From ...) To '/tmp/filename.csv' With CSV;
COPY (SELECT * FROM ...) TO '/tmp/filename.csv' (format CSV);
So the 162 rows of my output table have been copied in the shell. How can I paste or move them to a csv file?
The result is the CSV file. Open it with any spreadsheet program using matching delimiters. Per documentation:
The default is a tab character in text format, a comma in CSV format