Re: proposal \gcsv

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: proposal \gcsv
Дата
Msg-id CAFj8pRDqgii0a0d6KSw9k8m-cj-vXhiBFpfWC4W6uJ9LR+e3Yw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: proposal \gcsv  (David Fetter <david@fetter.org>)
Список pgsql-hackers


so 29. 2. 2020 v 18:06 odesílatel David Fetter <david@fetter.org> napsal:
On Sat, Feb 29, 2020 at 11:59:22AM +0100, Pavel Stehule wrote:
> so 29. 2. 2020 v 11:34 odesílatel Vik Fearing <vik@postgresfriends.org>
> napsal:
>
> > On 29/02/2020 06:43, Pavel Stehule wrote:
> > > Hi
> > >
> > > I would to enhance \g command about variant \gcsv
> > >
> > > proposed command has same behave like \g, only the result will be every
> > > time in csv format.
> > >
> > > It can helps with writing psql macros wrapping \g command.
> > >
> > > Options, notes?
> >
> > But then we would need \ghtml and \glatex etc.  If we want a shortcut
> > for setting a one-off format, I would go for \gf or something.
> >
> >     \gf csv
> >     \gf html
> >     \gf latex
> >
>
> usability of html or latex format in psql is significantly lower than csv
> format. There is only one generic format for data - csv.

Not exactly.  There's a lot of uses for things along the lines of

\gf json
\gf yaml

I'd rather add a new \gf that takes arguments, as it seems more
extensible. For example, there are uses for

I implemented \gf by Vik's proposal


\gf csv header

if no header is the default, or

\gf csv noheader

It is little bit hard (although it looks simply).

The second option of this command can be file - and it reads all to end of line. So in this case a implementation of variadic parameters is difficult.

Motivation for this patch is a possibility to write macros like

postgres=# \set gnuplot '\\g | gnuplot -p -e "set datafile separator \',\'; set key autotitle columnhead; set terminal dumb enhanced; plot \'-\'with boxes"' 

postgres=# \pset format csv

postgres=# select i, sin(i) from generate_series(0, 6.3, 0.05) g(i) :gnuplot


with \gf csv I can do almost what I need.

\set gnuplot '\\gf csv | gnuplot -p -e "set datafile separator \',\'; set key autotitle columnhead; set terminal dumb enhanced; plot \'-\'with boxes"'


if header is the default.

Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: proposal \gcsv
Следующее
От: Ranier Vilela
Дата:
Сообщение: Re: Broken resetting of subplan hash tables