Re: proposal - support tsv output format for psql

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal - support tsv output format for psql
Date: 2020-12-23 15:13:23
Message-ID: CAFj8pRDwmoc8k-g3Qzh2FOw+izmsWy9CL+agMha1bYEPK2kMGQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

st 23. 12. 2020 v 15:21 odesílatel Bruce Momjian <bruce(at)momjian(dot)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(at)momjian(dot)us> https://momjian.us
> EnterpriseDB https://enterprisedb.com
>
> The usefulness of a cup is in its emptiness, Bruce Lee
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Karlsson 2020-12-23 15:19:27 Re: Discarding DISCARD ALL
Previous Message Vladimir Sitnikov 2020-12-23 14:47:15 Re: Discarding DISCARD ALL