try to use the Duplicate merging feature. As it is likely to fail, please note of my next response as your emergency measure...
Better safe than sorry...
iMac or Macbooks will try to duplicate and merge and 2 serious problems happens after...
1. Entries get mixed up.
2. You lose all your contacts except for a few.
How to recover from the damage Apple inflicts on your contacts:
1. Local memory - Quickly go to your iPhone or iPad ( assuming you have one ).
go to Settings - iCloud - turn off Contacts ( this should save your contacts in your phone memory now )
try to recreate your contacts from this local memory version of your Contacts.
2. Restore - go to iCloud on the web and restore your Contacts to a last known archive.
If you accidentally deleted your calendars, reminders, or contacts from iCloud - Apple Support
Never use the duplicate feature again. And write to Apple to complain.