Re: csv format for psql

Fabien COELHO <coelho@cri.ensmp.fr>

From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Daniel Verite <daniel@manitou-mail.org>
Cc: Pavel Stehule <pavel.stehule@gmail.com>, Peter Eisentraut <peter.eisentraut@2ndquadrant.com>, Isaac Morland <isaac.morland@gmail.com>, "David G. Johnston" <david.g.johnston@gmail.com>, David Steele <david@pgmasters.net>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2018-08-10T13:32:08Z
Lists: pgsql-hackers
Hello Daniel,

> PFA an updated version.
> Usage from the command line:
> $ psql --csv	      # or -P format=csv
> $ psql --csv -P fieldsep_csv=";"  # for non-comma csv separator
>
> From inside psql:
>
> \pset format csv
> \pset fieldsep_csv '\t'

Patch applies cleanly, compiles, global make check ok.

Doc: "according to the csv rules" -> "according to csv rules."?

Doc: "RFC-4180" -> "RFC 4180"?

The previous RFC specifies CRLF as eol, but '\n' is hardcoded in the 
source. I'm fine with that, but I'd suggest that the documentation should 
said which EOL is used.

ISTM that "--csv" & "-C" are not documented, neither in sgml nor under
--help.

"fieldsep_csv" does not show on the list of output options under "\?".

There seems to be a test in the code to set an empty string "" by default,
but it is unclear to me when this is triggered.

I'd tend to use "CSV" instead of "csv" everywhere it makes sense, eg in 
the doc (CSV rules) and in variable names in the code (FooCsv -> FooCSV?), 
but that is pretty debatable.

-- 
Fabien.


Commits

  1. Add CSV table output mode in psql.

  2. Reorganize format options of psql in alphabetical order

  3. Complete TODO item: