Re: proposal - support tsv output format for psql

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: proposal - support tsv output format for psql
Дата
Msg-id CAFj8pRDwmoc8k-g3Qzh2FOw+izmsWy9CL+agMha1bYEPK2kMGQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: proposal - support tsv output format for psql  (Bruce Momjian <bruce@momjian.us>)
Ответы Re: proposal - support tsv output format for psql  (Andrew Dunstan <andrew@dunslane.net>)
Список pgsql-hackers


st 23. 12. 2020 v 15:21 odesílatel Bruce Momjian <bruce@momjian.us> napsal:
On Wed, Dec 23, 2020 at 07:18:24AM +0100, Pavel Stehule wrote:
> Hi
>
> I am playing with clipboard on Linux, and I found a way, how to redirect psql
> output to clipboard via wl-copy or xclip and then to Libre Office. Now it looks
> so best format is tsv
>
> select * from pg_database \g (format=tsv) | wl-paste -t application/
> x-libreoffice-tsvc
>
> Implementation of tsv format should not be hard.
>
> What do you think about this?

How would you handle tabs in the data?

This is a hard question.  tabs in data in tsv are handled by backslash escaping.

Unfortunately, after some check, the LibreOffice Calc has its own format. It is not true tsv. Looks much more like CSV with a tabelator as a separator. And the current implementation is buggy. It is working well only when data doesn't hold some special chars :-/. The special chars are deleted when data is exported from LO, and when data are imported with some special chars, then the imported line can be deformated. Looks so LO should be fixed first.

This command is working well - comma, quotes, or double quotes are working

select * from foo  \g (format=csv tuples_only=on csv_fieldsep='\t') | wl-copy -t application/x-libreoffice-tsvc

But \n or \t does problems due bug in LO side

After this second check, I think the new format is not necessary, because tsv in LO is not tsv, but it is cracked csv

Pavel






--
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EnterpriseDB                             https://enterprisedb.com

  The usefulness of a cup is in its emptiness, Bruce Lee

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Vladimir Sitnikov
Дата:
Сообщение: Re: Discarding DISCARD ALL
Следующее
От: Andreas Karlsson
Дата:
Сообщение: Re: Discarding DISCARD ALL