in reply to Re^2: Unable to load entire CSV file into DB
in thread Unable to load entire CSV file into DB

I expect the file format will be the issue, quite possibly the line endings. The first simple thing in your upload is to do this:

$buffer =~ s/[\r\n]+/\n/g;

to standardise all your line endings. You could use \r if you want but \n is the default, the standard .... and it's less typing in your LOAD DATA.

If that does not work then I suggest you use perl to read and validate the uploaded file before you pass it to mysql. I too suggest trying to load the file manually. You could download the file and try loading it into a local MySQL DB if you don't have access to the remote one.

cheers

tachyon

Replies are listed 'Best First'.
Re^4: Unable to load entire CSV file into DB
by bradcathey (Prior) on Nov 07, 2004 at 12:46 UTC

    Great suggestion, I've written this in as one more safeguard. However, I don't understand all that I'm seeing when I check for ascii or hex values. Here's a dump of a file that looks like this:

    ,AL,2 ,AK,4

    in ascii

    A--65 L--76 ,--44 2--50 --13 ,--44 A--65 K--75 ,--44 4--52 --13

    What is the blank spot? Even if it's a new line, shouldn't it have a value? Just curious.


    —Brad
    "Don't ever take a fence down until you know the reason it was put up." G. K. Chesterton

      It's printing the value, which is a newline, then showing its numeric (decimal) value. So you see the newline, which shows up as a blank line, then the 13. 13 is a CR.

        Of course! I get it, thanks.


        —Brad
        "Don't ever take a fence down until you know the reason it was put up." G. K. Chesterton