Instead of using the script, use the simple queries to achieve the updates
Create one temp table say, update_names with two column "sku, new_name and row_id"
CREATE TABLE update_names (
id INT NOT NULL AUTO_INCREMENT,
sku VARCHAR(255) NOT NULL,
new_name VARCHAR(255) NOT NULL,
row_id VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
);
Import the csv file into the temp table
LOAD DATA INFILE 'file_path'
INTO TABLE update_names
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
Update the temp table with row_id (its used to find the product in eav tables since name was stored in varchar table with attribute_id 73)
update update_names un join catalog_product_entity cv on cv.sku = un.sku set un.row_id = cv.row_id;
Use the below query to update all product names to the new name in the temp table
update catalog_product_entity_varchar cv join update_names un on un.row_id = cv.row_id and cv.attribute_id = 73 set cv.value = un.new_name;
Delete the temp table, once you verified the new name for the product
delete table update_names;