Conditional update/insert's on MySQL are quite easy, you can do something like
$result = mysql_query("UPDATE table SET (values) WHERE id = $id");
if(!$result){
$result = mysql_query("INSERT INTO table VALUES (...)");
}
Deleting is a bit more tricky since theres no frame of reference. I assume that if a record is not in the CSV then it should be deleted?
What are the 'rules' for the process?