Forum Moderators: coopster
$file = "myfile.txt";// Location of my file
$data = explode("\n", file_get_contents($file));// Read the file contents
unlink($file);// Immediately delete the file so new entries written to it are separate than the entries stored in the memory of this script
unset($data[count($data)-1]);// Removes last blank line
$hopper = count($data);
for($group = ceil($hopper/500); $group > 0; $group--){
$insert = "";
$lineCount = ($hopper > 500) ? 500 : $hopper;
for($lines = $lineCount; $lines > 0; $lines--){
$part = explode(",", $data[($lines-1)]);
$insert .= "... {$data[0]} ... {$data[1]} ...";// Creates a formatted version I can send to the api
$hopper--;}
... // Sends this batch to the API
}
$file = "myfile.txt";
$data = file_get_contents($file);
$entry_length = 123;
$process = 500;
$bytes_to_process = $entry_length * $process;
$fh = fopen($file, "w");
fwrite($fh, substr($data, $bytes_to_process));
fclose($fh);
$insert = substr($data, 0, $bytes_to_process);
... send $insert string to the API