Re: Two small questions re/ COPY CSV data into table

2019-06-05 Thread Matthias Apitz
El día Tuesday, June 04, 2019 a las 07:20:54PM +0200, Matthias Apitz escribió: > El día Tuesday, June 04, 2019 a las 05:56:49PM +0100, Andrew Gierth escribió: > > > If you use COPY ... WITH DELIMITER '|' (i.e. text mode, not CSV mode) > > then the \| is accepted as being a literal | and the

Re: Two small questions re/ COPY CSV data into table

2019-06-04 Thread Francisco Olarte
Mathias: On Tue, Jun 4, 2019 at 8:35 PM Matthias Apitz wrote: > El día Tuesday, June 04, 2019 a las 05:41:43PM +0200, Francisco Olarte > escribió: > > On Tue, Jun 4, 2019 at 5:03 PM Matthias Apitz wrote: > > > Well, it's not strictly CSV, but it is what the Sybase tool produces. The > > >

Re: Two small questions re/ COPY CSV data into table

2019-06-04 Thread Andrew Gierth
> "Matthias" == Matthias Apitz writes: Matthias> it is exported into the file as Matthias> cmd \| lpr ... Matthias> because the export delimiter is set to '|'; Matthias> the COPY in text mode was complaining because it interpreted Matthias> the | of the sequence \| as an

Re: Two small questions re/ COPY CSV data into table

2019-06-04 Thread Matthias Apitz
El día Tuesday, June 04, 2019 a las 05:56:49PM +0100, Andrew Gierth escribió: > Matthias> The new DELIMITER for PG is then vtab and the | is just a char in > the > Matthias> data (in the example above a pipe of two UNIX cmd). > > Yes, but why? > > If you use COPY ... WITH DELIMITER '|' (i.e.

Re: Two small questions re/ COPY CSV data into table

2019-06-04 Thread Andrew Gierth
> "Matthias" == Matthias Apitz writes: Matthias> sed 's/|/\v/g' < table-from-Sybase | sed 's/\\\v/|/g' > table-for-copy >> What on earth is this supposed to achieve? Matthias> It first translates any char '|' to vtab and then any '\vtab' Matthias> (i.e. a backslash followed by a

Re: Two small questions re/ COPY CSV data into table

2019-06-04 Thread Matthias Apitz
El día Tuesday, June 04, 2019 a las 04:41:47PM +0100, Andrew Gierth escribió: > Matthias> I do load this now with COPY in mode TEXT and modify the data > Matthias> before with: > > Matthias> sed 's/|/\v/g' < table-from-Sybase | sed 's/\\\v/|/g' > > table-for-copy > > What on earth is this

Re: Two small questions re/ COPY CSV data into table

2019-06-04 Thread Andrew Gierth
> "Matthias" == Matthias Apitz writes: >> That sounds like the file is not actually a CSV - why do you think >> it is? Matthias> Well, it's not strictly CSV, In other words it's not a CSV at all. Matthias> I do load this now with COPY in mode TEXT and modify the data Matthias> before

Re: Two small questions re/ COPY CSV data into table

2019-06-04 Thread Matthias Apitz
El día Tuesday, June 04, 2019 a las 11:32:45AM +0100, Andrew Gierth escribió: > Matthias> 2. The CSV export is done by some Sybase tool which escapes > Matthias> the delimiter as '\|', i.e. putting a backslash before the > Matthias> delimiter. I found no way that COPY understands this >

Re: Two small questions re/ COPY CSV data into table

2019-06-04 Thread Andrew Gierth
> "Matthias" == Matthias Apitz writes: Matthias>... WITH DELIMITER '|', FORMAT CSV ; I think you misread the docs; the new-style syntax would be COPY ... WITH (DELIMITER '|', FORMAT CSV); where the parens are not optional. The old-style syntax with no parens after WITH is what you

Two small questions re/ COPY CSV data into table

2019-06-04 Thread Matthias Apitz
Hello, I'm using COPY to load CSV data into the table in PG 10.x and have to simple questions: 1. I do use as command: COPY adm_cat FROM '/home/sisis/PostgreSQL/PDcsv/adm_cat.load' WITH DELIMITER '|' CSV ; which works fine. When I read the PG docs the syntax should be ... WITH