$load_query = "LOAD DATA LOCAL INFILE '{$file}' INTO TABLE `{$table}`
FIELDS TERMINATED BY ',' ENCLOSED BY '\"' (col1, col2, ... , @col_with_spaces)
SET col_with_spaces = RTRIM(@col_with_spaces);";
In questo modo non dovrai pre-elaborare il file né creare altri aggiornamenti sulla tabella.