Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm trying to load a .csv file into my database with many lines of input from a website I'm working on. For some reason I can load files multiple times (over and over) into the database but they have to have less than 73 lines of input. I don't see any problem with the input for the 73rd line.

I'm doing this in php and mysql

if(move_uploaded_file($path, $target_path))
{
  $sql = "LOAD DATA INFILE '" . $target_path . "' INTO TABLE `mydb`.`testtable` 
  CHARACTER SET utf8 FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\"'
  LINES TERMINATED BY '\r\n' 
  IGNORE 1 LINES 
  (`num`, @FieldNum, @CommonName, @LocalityRemarks ... )
  SET
  FieldNum = NULLIF(@FieldNum, ''), CommonName = NULLIF(@CommonName, ''), 
  LocalityRemarks = NULLIF(@LocalityRemarks, '')  ... );";

the size limit in my php.ini is 8M

I can have past 1000 lines in the database table when testing the loading of files less than 73


So the SQL is fine. There seems to be something going on with the php.

share|improve this question

migrated from stackoverflow.com May 25 '13 at 5:15

This question came from our site for professional and enthusiast programmers.

    
Sound's like script time or memory limit, which language are you using? –  Goran Lepur May 24 '13 at 22:28
    
post that puppy someplace so we can look at it. –  Drew Pierce May 24 '13 at 22:30
    
also try this. create a dummy table so there is nothing in it. then delete the crap after row 72. then cut and paste 1 to 72 to bottom, see if you can load in 144 rows –  Drew Pierce May 24 '13 at 22:32
    
have you checked and double-checked the line termination? I had huge problems with LOAD DATA INFILE from third party sources due to this. I ended up having to write a pre-processing script to convert all the line feeds into the kind expected by LOAD DATA INFILE. (it's a real shame mySQL can't be clever enough to accept various possible line endings) –  Spudley May 24 '13 at 22:57
1  
What error messages do you get? –  Mat May 25 '13 at 6:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.