in reply to Re: Problem uploading 'large' CSV file using DBI
in thread Problem uploading 'large' CSV file using DBI

I'm not receiving any type of error message. When I check the SQL table after running the script only the first line appears with a snippet of the second line's information appearing in the last column.

Teacher"2,"01
appears in the last column. The snippet of the second line is: 2,"01 (Teacher" from the first line) in the last column and then no other information is input into the database. Is there any more information that is needed?
#------------------------------ db operations sub execute_it { my ($dbh, $stmt) = @_; print "Content-type: text/html\n\n"; print "Here1".Dumper ($dbh, $stmt); $sth = $dbh->prepare($stmt); $sth->execute(); return ($sth); } Content-type: text/html Here1 $VAR1 = bless( {}, 'DBI::db' ); $VAR2 = 'LOAD DATA LOCAL INFILE "../file.csv" INTO TABLE table_name FI +ELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY """" LINES TERMINATED B +Y "\r" IGNORE 1 LINES '; sub close_db { my ($dbh, $sth) = shift; if ($sth) { $sth->finish(); $dbh->disconnect(); } }
"Recognizing who we aren't is only the first step toward knowing who we are." - Os Guinness

Replies are listed 'Best First'.
Re^3: Problem uploading 'large' CSV file using DBI
by diotalevi (Canon) on Jul 27, 2005 at 03:49 UTC
    Perhaps your line endings aren't Mac-ish like \r. Perhaps they're UNIXy like \n or DOSish like \r\n.
      I had already tried "\r" and "\r\n", but not "\n". Using "\n" everything loaded straight in to the database flawlessly!!!!!!!

      Thank you so much. Now how do I give points and is there a standard way to show the problem has been solved?

      In addition, is there a simple way to tell what is being used to end a line?