Re: Re: csv format for psql

2018-03-28 Thread Pavel Stehule
2018-03-28 10:24 GMT+02:00 Fabien COELHO : > > Hello Pavel, > > I'd like to convince you to compromise, because otherwise I'm afraid we >>> will not get this feature. >>> >> >> [...] >> >>> >>> The only no-surprise, no-behavioral-change, alternative I see is to have >>> a >>> csv-specific fieldsep

Re: Re: csv format for psql

2018-03-28 Thread Fabien COELHO
Hello Pavel, I'd like to convince you to compromise, because otherwise I'm afraid we will not get this feature. [...] The only no-surprise, no-behavioral-change, alternative I see is to have a csv-specific fieldsep. I'm not keen on that one because it is yet another variable, one has to rem

Re: Re: csv format for psql

2018-03-27 Thread Pavel Stehule
2018-03-27 11:35 GMT+02:00 Fabien COELHO : > > Hello Pavel, > > I'd like to convince you to compromise, because otherwise I'm afraid we > will not get this feature. > > 1. use special default string for formats that doesn't field sep - like >>> "not used" or some 2. I can implemet the op

Re: Re: csv format for psql

2018-03-27 Thread Fabien COELHO
Hello Pavel, I'd like to convince you to compromise, because otherwise I'm afraid we will not get this feature. 1. use special default string for formats that doesn't field sep - like "not used" or some 2. I can implemet the option fieldsep_default - very similary to fieldsep_zero to reset

Re: Re: csv format for psql

2018-03-26 Thread Pavel Stehule
2018-03-26 20:26 GMT+02:00 Daniel Verite : > Pavel Stehule wrote: > > > b) the list of pset options is bloating - every possible new format can > > introduce fieldsep_X option > > What new format? > The usefulness of fieldsep does not extend outside of xSV, and it's > no suprise that there

Re: Re: csv format for psql

2018-03-26 Thread Daniel Verite
Pavel Stehule wrote: > b) the list of pset options is bloating - every possible new format can > introduce fieldsep_X option What new format? The usefulness of fieldsep does not extend outside of xSV, and it's no suprise that there have been no other use for a fieldsep-like variable until

Re: Re: csv format for psql

2018-03-26 Thread Pavel Stehule
2018-03-26 14:44 GMT+02:00 Daniel Verite : > Pavel Stehule wrote: > > > implemented in attached patch > > Consider your initial output of \pset, when no option is specified > = > $ ./psql > psql (11devel) > Type "help" for help. > > postgres=# \pset > border

Re: Re: csv format for psql

2018-03-26 Thread Daniel Verite
Pavel Stehule wrote: > implemented in attached patch Consider your initial output of \pset, when no option is specified = $ ./psql psql (11devel) Type "help" for help. postgres=# \pset border 1 columns 0 expanded off fie

Re: Re: csv format for psql

2018-03-25 Thread Pavel Stehule
2018-03-25 18:02 GMT+02:00 Pavel Stehule : > > > 2018-03-25 15:21 GMT+02:00 Fabien COELHO : > >> >> >> Hello Pavel, >> >> [...] >>> it is correct. Default format is aligned, that doesn't use fieldsep. >>> >> >> My comment is that currently fieldsep is kind of a variable, the value of >> which

Re: Re: csv format for psql

2018-03-25 Thread Pavel Stehule
2018-03-25 15:21 GMT+02:00 Fabien COELHO : > > > Hello Pavel, > > [...] >>> >> it is correct. Default format is aligned, that doesn't use fieldsep. >> > > My comment is that currently fieldsep is kind of a variable, the value of > which is displayed and reliable wrt commands executed afterwards, a

Re: Re: csv format for psql

2018-03-25 Thread Fabien COELHO
Hello Pavel, [...] it is correct. Default format is aligned, that doesn't use fieldsep. My comment is that currently fieldsep is kind of a variable, the value of which is displayed and reliable wrt commands executed afterwards, and the proposed approach changes that by adding a new "defau

Re: Re: csv format for psql

2018-03-24 Thread Pavel Stehule
2018-03-24 10:06 GMT+01:00 Fabien COELHO : > > Hello Pavel, > > I'm suggesting to add \csv which would behave like \H to toggle CSV mode so as to improve this situation, with a caveat which is that toggling back \csv would have forgotted the previous settings (just l

Re: Re: csv format for psql

2018-03-24 Thread Fabien COELHO
Hello Pavel, I'm suggesting to add \csv which would behave like \H to toggle CSV mode so as to improve this situation, with a caveat which is that toggling back \csv would have forgotted the previous settings (just like \H does, though, so would for instance reset to aligned wit

Re: Re: csv format for psql

2018-03-24 Thread Pavel Stehule
minor fix > > another fix in help Pavel postgres=# \f Field separator is "". postgres=# \pset format csv Output format is csv. postgres=# \f Field separator is ",". postgres=# \pset format unaligned Output format is unaligned. postgres=# \f Field separator is "|". postgres=# \f ; Field separator

Re: Re: csv format for psql

2018-03-24 Thread Pavel Stehule
minor fix > all is working now [pavel@nemesis postgresql]$ psql --csv -F ';' -c "table foo" postgres a;b;c 3;4;Nazdar 3;4;Nazdar [pavel@nemesis postgresql]$ psql -F ';' --csv -c "table foo" postgres a;b;c 3;4;Nazdar 3;4;Nazdar [pavel@nemesis postgresql]$ psql --csv -c "table foo" postgres a,

Re: Re: csv format for psql

2018-03-24 Thread Pavel Stehule
2018-03-24 8:24 GMT+01:00 Pavel Stehule : > > > 2018-03-24 8:15 GMT+01:00 Fabien COELHO : > >> >> Hello Pavel, >> >> The patch adds a simple way to generate csv output from "psql" queries, much simpler than playing around with COPY or \copy. It allows to generate a clean CSV dump fr

Re: Re: csv format for psql

2018-03-24 Thread Pavel Stehule
2018-03-24 8:15 GMT+01:00 Fabien COELHO : > > Hello Pavel, > > The patch adds a simple way to generate csv output from "psql" queries, >>> much simpler than playing around with COPY or \copy. It allows to >>> generate >>> a clean CSV dump from something as short as: >>> >>> sh> psql --csv -c 'TA

Re: Re: csv format for psql

2018-03-24 Thread Fabien COELHO
Hello Pavel, The patch adds a simple way to generate csv output from "psql" queries, much simpler than playing around with COPY or \copy. It allows to generate a clean CSV dump from something as short as: sh> psql --csv -c 'TABLE foo' > foo.csv Documentation is clear. Test cover a signific

Re: Re: csv format for psql

2018-03-23 Thread Pavel Stehule
2018-03-23 18:55 GMT+01:00 Fabien COELHO : > > Hello Daniel, > > Do you know when you'll have an updated patch that addresses the minor >>> issues brought up in review and the concern above? >>> >> >> Here's an update addressing the issues discussed: >> >> - fieldsep and recordsep are used, no mor

Re: Re: csv format for psql

2018-03-23 Thread Pavel Stehule
2018-03-23 12:59 GMT+01:00 Daniel Verite : > Pavel Stehule wrote: > > > It should not be hard. All formats can has '|' like now, and csv can > have a > > ',' - then if field separator is not explicit, then default field > separator > > is used, else specified field separator is used. > > >

Re: Re: csv format for psql

2018-03-23 Thread Fabien COELHO
Hello Daniel, Do you know when you'll have an updated patch that addresses the minor issues brought up in review and the concern above? Here's an update addressing the issues discussed: - fieldsep and recordsep are used, no more fieldsep_csv - the command line option is --csv without short o

Re: Re: csv format for psql

2018-03-23 Thread Daniel Verite
Pavel Stehule wrote: > It should not be hard. All formats can has '|' like now, and csv can have a > ',' - then if field separator is not explicit, then default field separator > is used, else specified field separator is used. > > You can see my idea in attached patch With that patch, c

Re: Re: csv format for psql

2018-03-22 Thread Pavel Stehule
2018-03-22 20:10 GMT+01:00 Pavel Stehule : > > > 2018-03-22 19:28 GMT+01:00 Pavel Stehule : > >> >> >> 2018-03-22 18:38 GMT+01:00 Fabien COELHO : >> >>> >>> Hello Pavel, >>> >>> Using \pset format csv means overwriting field sep every time - nobody uses | >>> >>> Yep. The alternativ

Re: Re: csv format for psql

2018-03-22 Thread Pavel Stehule
2018-03-22 19:28 GMT+01:00 Pavel Stehule : > > > 2018-03-22 18:38 GMT+01:00 Fabien COELHO : > >> >> Hello Pavel, >> >> Using \pset format csv means overwriting field sep every time - nobody >>> uses >>> | >>> >> >> Yep. The alternative is to have a csv-specific separator variable, which >> does no

Re: Re: csv format for psql

2018-03-22 Thread Pavel Stehule
2018-03-22 18:38 GMT+01:00 Fabien COELHO : > > Hello Pavel, > > Using \pset format csv means overwriting field sep every time - nobody uses >> | >> > > Yep. The alternative is to have a csv-specific separator variable, which > does not seem very useful, must be remembered, but this is indeed debat

Re: Re: csv format for psql

2018-03-22 Thread Fabien COELHO
Hello Pavel, Using \pset format csv means overwriting field sep every time - nobody uses | Yep. The alternative is to have a csv-specific separator variable, which does not seem very useful, must be remembered, but this is indeed debatable. I think so dependency on order of psql argument

Re: Re: csv format for psql

2018-03-22 Thread Pavel Stehule
Hi 2018-03-22 16:30 GMT+01:00 Daniel Verite : > David Steele wrote: > > > Do you know when you'll have an updated patch that addresses the minor > > issues brought up in review and the concern above? > > Here's an update addressing the issues discussed: > > - fieldsep and recordsep are us

Re: Re: csv format for psql

2018-03-22 Thread Daniel Verite
David Steele wrote: > Do you know when you'll have an updated patch that addresses the minor > issues brought up in review and the concern above? Here's an update addressing the issues discussed: - fieldsep and recordsep are used, no more fieldsep_csv - the command line option is --csv w

Re: Re: csv format for psql

2018-03-21 Thread David Steele
Hi Daniel, On 3/10/18 1:49 AM, Fabien COELHO wrote: > >>> recordsep in the unaligned mode doesn't play the role of a line ending >>> because the last line is not finished by recordsep. According to the >>> source >>> code, this is intended, see print_unaligned_text() in print.c: >> >> Something e