I have the following code which takes a $filename
and loops through it. If the 9th column is in an array of values (not shown here), I ignore it.
Otherwise I write the row to a file which name is based on the 3rd column.
if (($handle = fopen($filename, "r")) !== FALSE) {
fgetcsv($handle);
while (($line = fgetcsv($handle, 2000, ";")) !== FALSE) {
if (!in_array($line[8], $exclude)) {
$d = str_replace('/','',$line[2]);
$f = fopen($base.$d.'.csv', "a");
fputcsv($f, $line);
fclose($f);
unset($line);
}
}
fclose($handle);
}
This works fine. However it's very slow. I have a 200Mb CSV it's looping through.
My question is whether it can be optimised and/or whether I am doing anything tragically wrong?
Thanks