ここでいくつかの仮定を立てます... ソリューションを自分に合ったものにする必要があります。
csv ファイルの 2 番目のフィールドは、ファイルを比較したときに製品が更新されたことを示すものであり、最終更新のタイムスタンプのようなものであると想定しています。
$prodFile = fopen("current-products.csv", "r");
// build a list of all of the sku's in prodFile
$prods = array();
while ($rec = fgetcsv($prodFile)){
// I am assuming the second field is an updated timestamp
$prods[$rec[0]] = $rec[1];
}
fclose($prodFile);
$newProdFile = fopen("new-products.csv", "r");
$addFile = fopen("productsToAdd.csv", "w");
$updateFile = fopen("productsToUpdate.csv", "w");
while ($rec = fgetcsv($newProdFile)){
if (!array_key_exists($rec[0], $prods)){
fputcsv($addFile, $rec);
}
if (array_key_exists($rec[0], $prods) &&
$prods[$rec[0]] != $rec[1]){
fputcsv($updateFile, $rec);
}
}
fclose($newProductFile);
fclose($addFile);
fclose($updateFile);