Upload the data in a temporary table, then process the data into the operational table.
Then you have the option to create the key from different fields and use this to retrieve the record with this key from the operational table and if not found create the record, else update the record.
To completely make sure that ther are no concurrency issues you’ll need to process the records in the order thay come in, for that the process queue module from the appstore might be useful.