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
>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
>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.