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

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Matthias Apitz <guru(at)unixarea(dot)de>
Cc: Postgres general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Two small questions re/ COPY CSV data into table
Date: 2019-06-04 16:56:49
Message-ID: 87blzd8fdq.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>>>> "Matthias" == Matthias Apitz <guru(at)unixarea(dot)de> 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 vtab) back to the char |

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. text mode, not CSV mode)
then the \| is accepted as being a literal | and the unescaped | is
treated as a delimiter. What is the point of the substitutions?

--
Andrew (irc:RhodiumToad)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message paul.malm 2019-06-04 17:18:45 Re: psql \copy
Previous Message Rob Northcott 2019-06-04 16:54:55 Query very different speeds on seemingly similar data