我需要的代码是创建一个新的CSV并将其称为output_1.csv,将100行写入该CSV,然后保存它,创建output_2.csv并写入100行,并继续创建100行文件,直到所有信息都用尽。有人可以帮我弄这个吗?PHP和CSV文件+增量
这是我必须与之合作。目前,它只是写入1个文件,直到所有内容都用完为止。实际上,我需要一次做10万行,但为了测试目的,100行很好,我可以改变它。
<?php
include "base.php";
//$result1 = mysql_query("SELECT * FROM pts_ultd , scrape_data WHERE pts_ultd.B == scrape_data.R");
$a = "4";
$result1 = mysql_query("SELECT * FROM scrape_data , pts_ultd WHERE pts_ultd.P_B = scrape_data.S_R && pts_ultd.P_E != '".$a."' ");
//grab all the content
while($r=mysql_fetch_array($result1))
{
$A = $r["S_A"];
$B = $r["S_B"];
$C = $r["S_C"];
$D = $r["S_D"];
$E = $r["S_E"];
$F = $r["S_F"];
$G = $r["S_G"];
$H = $r["S_H"];
$I = $r["S_I"];
$J = $r["S_J"];
$K = $r["S_R"];
$L = $r["S_L"];
$M = $r["S_M"];
$N = $r["S_N"];
$O = $r["S_O"];
$P = $r["S_P"];
$Q = $r["S_Q"];
$R = $r["S_R"];
$S = $r["P_D"];
//this is where the intering of the data takes place currently..
$cvsData = $A . "," . $B . "," . $C . "," . $D . "," . $E . "," . $F . "," . $G . "," . $H . "," . $I . "," . $J . "," . $K . "," . $L . "," . $M . "," . $N . "," . $O . "," . $P . "," . $Q . "," . $R . "," . $S ."\n";
$fp = fopen("feed_output.csv","a"); // $fp is now the file pointer to file $filename
if($fp){
fwrite($fp,$cvsData); // Write information to the file
fclose($fp); // Close the file
} // end if
}//end while
?>
如果您提出具体问题,而不是要求人们为您编写代码,您将会有更多的运气。 – 2011-04-04 01:05:58