* Nick Arnett
> 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
> INFILE's defaults -- tab-separated fields and return-separated records.  I
> 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.

You should check this again...

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

It looks like you have the CRLF problem... Python on win platform outputs
CRLF for '\n', because that is normally the wanted line ending on windows
systems... open your file in binary mode to disable this feature:

f = open('datafile.sql','wb')

> That last field also seems to be truncated on the last record
> inserted.  I'm mystified.  Suggestions appreciated.

--
Roger


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to