AnsweredAssumed Answered

Write unique attribute value pairs

Question asked by BTLeslie on Jul 1, 2015
Latest reply on Jul 1, 2015 by rfairhur24

I've got a python script that looks for a field name in shapefiles and if it exists writes all unique attribute values to a text file, as follows:


testField = "MyField"

with open("myTextFile.txt", "a") as text file:
     fcs = arcpy ListFeatureClasses()
     for fc in fcs:
          fieldList = arcpy.ListFields(fc)
          fieldExists = False
          for field in fieldList:
               if == testField:
                    fieldExists = True
               values = [row[0] for row in arcpy.da.SearchCursor(fc,(testField))]
               uniqueValues = set(values)


Now I want to test for two fields and write all unique pairs of values to a text file and I'm a bit stuck can anyone help?.... (the test for whether the fields exist is easy, I figured that bit out, but how do I find unique pairs of values?)