As this is a codereview, let's review the PHP part as well. I doubt these improvements will add a lot of speed but they will definitely add to the main benefits of PHP code - the *clarity and conciseness*. And the time and effort spent for writing the code to do the job <?php $i_fp = fopen("inFile.csv","r"); $o_fp = fopen("outFile.csv","w"); while (($split = fgetcsv($i_fp, 0, ';')) !== FALSE) { { if($split[3] == 'E' || $split[3] == 'T') { fputcsv($o_fp, [ $split[0], $split[1], $split[3], $split[4], $split[5], $split[6], $split[10], $split[9],$split[11],$split[7],$split[32] ]); } }