Re: csv format for psql - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: csv format for psql
Date
Msg-id CAKFQuwb+DXLjj4kci3MWDtHq4wNHojcw=GwYvX5aVhzp3UDd0Q@mail.gmail.com
Whole thread Raw
In response to Re: csv format for psql  (Isaac Morland <isaac.morland@gmail.com>)
List pgsql-hackers
On Wed, Mar 28, 2018 at 4:19 PM, Isaac Morland <isaac.morland@gmail.com> wrote:
On 28 March 2018 at 15:43, Joshua D. Drake <jd@commandprompt.com> wrote:
On 03/28/2018 12:35 PM, David G. Johnston wrote:
I like to call it "Character Separated Values" now for just that reason.

Isn't the actual wording Character Delimited Values? I may be picking at hairs here but every single time I use anything to import a CSV or other delimited file (TAB or | usually) that is what the import screen says.

CSV stands for Comma Separated Values, and not anything else common as far as I can tell.

​Language evolves - Wikipedia just hasn't recognized this particular evolution yet :)

The actual reason I'm posting this is because some of the discussion has made me a bit confused: there is already a CSV format defined for the COPY command and used by the psql \copy. I just want to check that what is being discussed here would use the exact same format as the existing CSV COPY format; and the configurability of them should be the exact same options (which already includes being able to change the delimiter).

​Nope, the \copy meta-command, and corresponding COPY SQL command, have additional options that I don't believe will be accessible here.​  Specifically the "OIDS", "QUOTE", and various "FORCE_" options are not controllable, nor are ESCAPE and ENCODING (this last I think, or at least not as flexible).
 
I think it's important that Postgres not have two CSVs with slightly different behaviours. Indeed, psql could use COPY behind the scenes to generate the CSV output, which would guarantee no nasty surprises.

If this is already widely accepted or if I'm horribly misunderstanding the discussion then I'm sorry for the noise.

​I agree this is a possible approach but the way the thinking is presently is that this is just another "\pset format" option with forced defaults excepting the delimiter (DELIMITER),presence of the column names (HEADER)​, NULL (I think...) 

​Issuing \copy with the equivalent settings should result in the same output...but the two mechanisms are distinct for better and worse.

David J.

pgsql-hackers by date:

Previous
From: Isaac Morland
Date:
Subject: Re: csv format for psql
Next
From: Andrew Dunstan
Date:
Subject: Re: ALTER TABLE ADD COLUMN fast default