csv file with mysql
| From: | Chris Burger | Date: | Mon, 12 Mar 2001 22:05:00 +0000 |
| Subject: | csv file with mysql | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-7347@lists.php.net to get a copy of this message | ||
I'm loading a csv text file into a table in a mysql database, however it
seems to just stop after a while if the file is to big. For example if the
csv file is less than 10 megs I don't have a problem, however if it is more
it seems to to drop about half way thru the file.
here is the script I used
$fo = @fopen($datafile, "r") or die ("could not open $datafile");
while ($line = fgets ($fo,1024)) {
$line = ereg_replace ("\'","", $line);
$line = ereg_replace ("\"","", $line);
list ($loannumber, $transactionnumber, $transactioncode, $subtype,
$investornumber, $transactiondate, $nextduedate, $principalbalance,
$escrowbalance, $principalamount, $interestamount, $escrowamount,
$suspenceamount, $transactionamount, $transactiondescription, $feesamount,
$subtotal, $code1, $amount1, $code2, $amount2, $end) = explode(",", $line);
$query = "insert into $table
(loannumber, transactionnumber, transactioncode, subtype, investornumber,
transactiondate, nextduedate, principalbalance, escrowbalance,
principalamount, interestamount, escrowamount, suspenceamount,
transactionamount, transactiondescription, feesamount, subtotal, code1,
amount1, code2, amount2, end)
values
('$loannumber', '$transactionnumber', '$transactioncode',
'$subtype',
'$investornumber', '$transactiondate', '$nextduedate',
'$principalbalance',
'$escrowbalance', '$principalamount', '$interestamount',
'$escrowamount',
'$suspenceamount', '$transactionamount', '$transactiondescription',
'$feesamount', '$subtotal', '$code1', '$amount1',
'$code2', '$amount2',
'$end')";
mysql_query($query) or die (mysql_error());
I'm new with php so any help would be appreciated.
Chris Burger