Re: [Qgis-developer] Finding duplicate records

2014-03-01 Thread Eric Goddard
Python can also be used to find duplicate attributes. It isn't as
straightforward as a sql query, but it works. And if your data isnt in
spatialite/postGIS, I don't know if you can do a select distinct without
creating a more complicated subquery using the expression builder. From the
console:

from collections import Counter

# get a reference to the layer to be searched
layer = iface.activeLayer()

# get the position in the attribute table of the attribute to be checked
idx = layer.fieldNameIndex('attribute_name')

# create a list of all the attribute values
attributeList = [feature.attributes()[idx] for feature in
layer.getFeatures()]

# print the duplicate entries in the attributeList
print([attribute for attribute, count in Counter(attributeList).items() if
count  1])


Eric



On Fri, Feb 28, 2014 at 8:32 PM, Alex Mandel tech_...@wildintellect.comwrote:

 On 02/28/2014 02:46 AM, Paolo Cavallini wrote:
  Hi all.
  I can't recall of any function or plugin to find duplicate data ona
  table of attributes: am I right, or am I forgetting something?
  Thanks in advance.
 

 I always use Spatialite or Postgis so I can run a DISTINCT function in a
 query, or GROUP BY what should be unique and get a count (if it's  1
 it's not unique). I'm not aware of any other way to check for duplicate
 data.

 Enjoy,
 Alex
 ___
 Qgis-developer mailing list
 Qgis-developer@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/qgis-developer

___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] Finding duplicate records

2014-03-01 Thread Paolo Cavallini
Il 01/03/2014 17:06, Eric Goddard ha scritto:
 Python can also be used to find duplicate attributes. It isn't as
 straightforward as a sql query, but it works. And if your data isnt in

Thanks to all. Seems a good exercise for a plugin.
All the best.
-- 
Paolo Cavallini - www.faunalia.eu
QGIS  PostGIS courses: http://www.faunalia.eu/training.html
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] Finding duplicate records

2014-02-28 Thread Paolo Cavallini
Hi all.
I can't recall of any function or plugin to find duplicate data ona
table of attributes: am I right, or am I forgetting something?
Thanks in advance.
-- 
Paolo Cavallini - www.faunalia.eu
QGIS  PostGIS courses: http://www.faunalia.eu/training.html
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] Finding duplicate records

2014-02-28 Thread Alex Mandel
On 02/28/2014 02:46 AM, Paolo Cavallini wrote:
 Hi all.
 I can't recall of any function or plugin to find duplicate data ona
 table of attributes: am I right, or am I forgetting something?
 Thanks in advance.
 

I always use Spatialite or Postgis so I can run a DISTINCT function in a
query, or GROUP BY what should be unique and get a count (if it's  1
it's not unique). I'm not aware of any other way to check for duplicate
data.

Enjoy,
Alex
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer