Re: COPY TO STDOUT WITH (FORMAT CSV, HEADER), and embedded newlines

2022-03-13 Thread Francisco Olarte
Dominique: On Fri, 11 Mar 2022 at 21:13, Dominique Devienne wrote: > But sure, if TEXT does the kind of pseudo-CSV I need, I'd change it to use it. Text, the original format for copy, is much easier to manage than CSV. It can easily be managed as you can split the whole input on newlines to get

Re: COPY TO STDOUT WITH (FORMAT CSV, HEADER), and embedded newlines

2022-03-13 Thread Francisco Olarte
Hi Daniel: On Fri, 11 Mar 2022 at 19:38, Daniel Verite wrote: > > These values are 'normal'. I'm not use to CSV, but I suppose > > such newlines > > must be encoded, perhaps as \n, since AFAIK CSV needs to be 1 line per row, > > no? > No, but such fields must be enclosed by double quotes, as docu

Re: COPY TO STDOUT WITH (FORMAT CSV, HEADER), and embedded newlines

2022-03-11 Thread Dominique Devienne
On Fri, Mar 11, 2022 at 8:32 PM Daniel Verite wrote: > Dominique Devienne wrote: > > so I can easily do that "\n" encoding myself, as a post-processing on > > the buffer I get back. > > Alternatively, it might be easier to use the default TEXT format of > COPY rather than CSV, as the TEXT

Re: COPY TO STDOUT WITH (FORMAT CSV, HEADER), and embedded newlines

2022-03-11 Thread Daniel Verite
Dominique Devienne wrote: > so I can easily do that "\n" encoding myself, as a post-processing on > the buffer I get back. Alternatively, it might be easier to use the default TEXT format of COPY rather than CSV, as the TEXT format already produces \n for line feeds, along with half a d

Re: COPY TO STDOUT WITH (FORMAT CSV, HEADER), and embedded newlines

2022-03-11 Thread Dominique Devienne
On Fri, Mar 11, 2022 at 7:38 PM Daniel Verite wrote: >> Dominique Devienne wrote: > > These values are 'normal'. I'm not used to CSV, but I suppose such newlines > > must be encoded, perhaps as \n, since AFAIK CSV needs to be 1 line per row, > > no? > > No, but such fields must be enclose

Re: COPY TO STDOUT WITH (FORMAT CSV, HEADER), and embedded newlines

2022-03-11 Thread Daniel Verite
Dominique Devienne wrote: > These values are 'normal'. I'm not use to CSV, but I suppose > such newlines > must be encoded, perhaps as \n, since AFAIK CSV needs to be 1 line per row, > no? No, but such fields must be enclosed by double quotes, as documented in RFC 4180 https://datatracker

Re: COPY TO STDOUT WITH (FORMAT CSV, HEADER), and embedded newlines

2022-03-11 Thread David G. Johnston
On Friday, March 11, 2022, Dominique Devienne wrote: > I've tracked these to text values in the DB with embedded > newlines. These values are 'normal'. I'm not use to CSV, but I suppose > such newlines > must be encoded, perhaps as \n, since AFAIK CSV needs to be 1 line per > row, no? Haven’t t

COPY TO STDOUT WITH (FORMAT CSV, HEADER), and embedded newlines

2022-03-11 Thread Dominique Devienne
Hi. It's my first time using COPY TO. And first time using built-in CSV support. Performs well. BUT... The code below (real code, but using a custom libpq wrapper lib) is run on a few tables, with unit tests that verify the number of lines of the output file. And for a few of those tables, there'