cat file.txt | psql -d dbname -c "copy mytable from stdin csv"