Re: Two small questions re/ COPY CSV data into table - Mailing list pgsql-general

From Andrew Gierth
Subject Re: Two small questions re/ COPY CSV data into table
Date
Msg-id 87blzd8fdq.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to Re: Two small questions re/ COPY CSV data into table  (Matthias Apitz <guru@unixarea.de>)
Responses Re: Two small questions re/ COPY CSV data into table
List pgsql-general
>>>>> "Matthias" == Matthias Apitz <guru@unixarea.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)



pgsql-general by date:

Previous
From: Rob Northcott
Date:
Subject: Query very different speeds on seemingly similar data
Next
From:
Date:
Subject: Re: psql \copy