I am trying to run a complex import task that reads a CSV. This import works fine except the server runs out of available memory to finish the task. I am trying to split the files into chunks of 1000 rows to allow the server to then process these “bite size” sections one by one. My CSplit however will not split the files. Have I got my syntax right.
I have checked that the directory is correct, and that the path to the command is correct and that the file is there but no luck.
Thanks in advance.
function processSplit() {
chdir('Files');
$dir = '*';
foreach (glob($dir) as $file) {
system(CSPLIT_PATH . " -k -n 4 -f ' " . $file . " ' 1000 '{1000}'");
}
}
The command line is incorrect.
You have:
system(CSPLIT_PATH . " -k -n 4 -f ' " . $file . " ' 1000 '{1000}'");Should be:
system(CSPLIT_PATH . " $file -k -n 4 -f ' " . $file . " ' 1000 '{1000}'");Besides, I would change
-f ' " . $file . " ', for you are creating a space in front and the back of the output file.