2

This question already has an answer here:

I have around 1 Lakh+ (100,000+) point features in my shapefile, which has some duplicate records in it. I had found the duplicate records present in the attribute table and print those in python console. But i want to select those duplicate features in attribute table so that i can delete those entries from attribute table. How should this can be done using python? I had attached my snippet for printing the duplicate records present.

from collections import Counter
layer = iface.activeLayer()
idx = layer.fieldNameIndex('name')
attributeList = [feature.attributes()[idx] for feature in layer.getFeatures()]
print([attribute for attribute, count in Counter(attributeList).items() if count > 1])

merged by PolyGeo Sep 27 '18 at 6:42

This question was merged with Python script for identifying duplicate records (follow up) because it is an exact duplicate of that question.