Export postgresql data to CSV from sql file

Sometimes you want to export data from a Postgresql database but that SQL query is so long, you'd need a seperate file for it.
You can use that file as input too:

psql -U username -h hostname database_name -t -A -F";" -f path/to/bigsql.sql > output.csv