Php and csv files + incriments + PLEASE HELP?
Posted: Sun Apr 03, 2011 7:56 pm
Hello, i need help and i need it fast! .. it's pretty self explanatory if you look at the code..
what i NEED this code to do is to create a new CSV and call it output_1.csv, write 100 lines to that CSV, then save it, create output_2.csv, and write up to 100 lines, and continue to create 100 line files until all info is exhausted. can someone help me with this?????
This is what i have to work with. At the moment, it just writes to 1 file until everything is exhausted. truthfully, i need this to do 100,000 lines at a time, but for testing purposes, 100 is fine, i can change it. PLEASE PLEASE HELP. i've maxed out my deadline for this! thanks in advance!!
by the way.. yeah, im sure your eyes got big when i said 100,000 lines.......... i know.............. i know... but that's what i need. we have about 8 million things i need to split up. take too long to explain, just help me get it done please please.
--------
what i NEED this code to do is to create a new CSV and call it output_1.csv, write 100 lines to that CSV, then save it, create output_2.csv, and write up to 100 lines, and continue to create 100 line files until all info is exhausted. can someone help me with this?????
This is what i have to work with. At the moment, it just writes to 1 file until everything is exhausted. truthfully, i need this to do 100,000 lines at a time, but for testing purposes, 100 is fine, i can change it. PLEASE PLEASE HELP. i've maxed out my deadline for this! thanks in advance!!
by the way.. yeah, im sure your eyes got big when i said 100,000 lines.......... i know.............. i know... but that's what i need. we have about 8 million things i need to split up. take too long to explain, just help me get it done please please.
--------
Code: Select all
<?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
?>