Delete duplicate contacts and contacts with more or less than X digits using Python

Photo by Brett Jordan on Unsplash

If you export the address book in CSV, you can delete duplicate contacts and also those with phone numbers with more or less than X digits.

First you need to export your contacts in CSV format.

For this tutorial we use python.

First you need to read the csv file:

To delete the contacts with the duplicate phone number do this command. You have to replace “Numero di telefono” with the name of the phone number column of your CSV file:

If you want to delete duplicate contacts based on multiple columns:

To delete contacts with more or less than X digits because they are invalid contacts.

After the various deletions of duplicate or invalid contacts, let’s go to save the CSV.

Now you can import the created CSV into your address book management system.

I’ll put below the complete code I used:

If you have any problems or if you have solved them in any other way do not hesitate to write them in the comments!

Robotics and Software engineering

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store