List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:March 22 2002 12:19am
Subject:Re: Extra return in last field in LOAD DATA INFILE?
View as plain text  
At 15:21 -0800 3/21/02, Nick Arnett wrote:
>I have something odd happening with a bulk insert file and haven't been able
>to find anything in docs or archives that gives me a clue what's going on.
>I'm creating a bulk insert file programmatically with Python.  Everything
>seems to work fine, except that in the last field of each record, a return
>character ('\n') is getting tacked onto the field data.  I'm using LOAD DATA

That's not a return, that's a linefeed (aka newline).  Do you mean \r
instead?  If so, the problem may be that your file is CRLF terminated,
and the CR is not being taken as part of the record terminator, so it
becomes part of the data.

>INFILE's defaults -- tab-separated fields and return-separated records.  I

The default is linefeed-separate, not return separated.

I suggest that you run your data file through a hex dump utility to see
what it really contains.  And that you avoid conflating return with linefeed,
because they're different, and not treating them as such will cause you
endless headaches.

>cannot figure out where this extra return is coming from.  It seems
>downright impossible for it to be there, since MySQL is correctly
>identifying the fields and records -- there are no warnings from LOAD DATA
>INFILE and I can see that all the records are being loaded.
>
>I've tried changing the Python statement between ending the print statement
>with "'\n'," and just letting it add the return as it does by default if
>there's no comma at the end of the statement -- no effect.
>
>I have also tried loading the bulk file from the MySQL client -- same thing
>happens.
>
>I'm as certain as I can be that Python is just putting one return character
>into the insert file, which is why I'm asking the question here, rather than
>on a Python list.
>
>I'm having flashbacks to CR/LF problems when moving Macintosh files to DOS!
>
>This is on Windows 2000, using Python 2.2 and MySQL 3.23.46-nt.
>
>That last field also seems to be truncated on the last record inserted.  I'm
>mystified.  Suggestions appreciated.
>
>Nick

Thread
Getting Found Count When Using LimitFletcher Sandbeck21 Mar
  • Re: Getting Found Count When Using LimitAllon Bendavid21 Mar
    • Re: Getting Found Count When Using LimitFletcher Sandbeck21 Mar
      • RE: Getting Found Count When Using LimitRoger Baklund21 Mar
        • Re: Getting Found Count When Using LimitJeff Kilbride24 Mar
    • Extra return in last field in LOAD DATA INFILE?Nick Arnett22 Mar
      • RE: Extra return in last field in LOAD DATA INFILE?Roger Baklund22 Mar
        • RE: Extra return in last field in LOAD DATA INFILE?Nick Arnett22 Mar
      • Re: Extra return in last field in LOAD DATA INFILE?Paul DuBois22 Mar