List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:June 10 1999 2:29am
Subject:Re: Weird import
View as plain text  
At 8:19 PM -0400 6/9/1999, Para-dox wrote:
>I'm using LOAD DATA LOCAL INFILE to import a file with weird
>properties....Its comma delimited and strings are enclosed by ", *but* \
>is not an escape character. Instead, when a literal " is needed, it simply
>puts two of them "". Example:
>
>
>123,"My field","Bah","Lets write a "" just to screw it up"
>
>
>What parameters to LOAD DATA INFILE can I use??


The MySQL manual says:

>For input, the @code{ENCLOSED BY} character, if present, is stripped from the
>ends of field values.  (This is true whether or not @code{OPTIONALLY} is
>specified; @code{OPTIONALLY} has no effect on input interpretation.)
>Occurrences of the @code{ENCLOSED BY} character preceded by the
>@code{ESCAPED BY} character are interpreted as part of the current field
>value.  In addition, duplicated @code{ENCLOSED BY} characters occurring
>within fields are interpreted as single @code{ENCLOSED BY} characters if the
>field itself starts with that character.  For example, if @code{ENCLOSED BY
>'"'} is specified, quotes are handled as shown below:
>
>@example
>"The ""BIG"" boss"  -> The "BIG" boss
>The "BIG" boss      -> The "BIG" boss
>The ""BIG"" boss    -> The ""BIG"" boss
>@end example

This suggests that FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY ''
should work.

--
Paul DuBois, paul@stripped
Northern League Chronicles: http://www.snake.net/nl/
Thread
Weird importPara-dox10 Jun
  • Re: Weird importPaul DuBois10 Jun
  • Weird importMichael Widenius10 Jun