The output from pg_restore --data-only -t my_table db.dump
basically is tab-separated headerless tabulated text with some comments and a few extra commands. A script to mangle it into csv with a tool like perl
or awk
would be pretty simple.
That said, personally I would:
Restore the table to a temporary database created for the purpose. If the table depends on custom types, functions, sequences, etc you will need to restore them too.
In
psql
,\copy the_table TO 'some_file.csv' WITH (FORMAT CSV, HEADER ON)
This way you can control the representation of nulls and lots more.