I want to update and create new data in the database by importing an excel csv

In my system I want the user to import a spreadsheet that contains data into the database, so far so good, the problem is that sometimes the spreadsheet is updated and when I import it it duplicates the information and I would like you to check if there is anything new, it would create new data and if there was something that was already there, it would update the data, does anyone know how to do this?


I have this screen, it works well to import, however, when I import again it duplicates the data


duplicate data screen



Below is the workflow of import button and database photo, please help me

There is a similar article here, can you check it?

  1. Save the data you’ll upload in a state
  2. Loop through that state
  3. Create a condition when ID is already exist then update the data

Can you show me how I do this? I’m having difficulty