Pages

Sunday, November 8, 2020

redirect result from psql to libreoffice calc

Sometimes can be useful to forward output query result from console to spreadsheet. Unfortunately, it is not trivial task, but it is not pretty hard too.

I have a table "obce" (It is "municipality" in Czech language), and I would to see the content of this table in spreadsheet. Then I can redirect output in csv format to libreoffice.

Now I can run psql and write command:

postgres=# select * from obce \g (format=csv) | cat > tmpfile.csv; libreoffice --view --calc tmpfile.csv "--infilter='Text - txt - csv (StarCalc)':44,34,0,1"; rm tmpfile.csv

The psql from Postgres 13 is required.

No comments:

Post a Comment