AnsweredAssumed Answered

Missing values in a dictionary?

Question asked by JB1234510 on May 29, 2020
Latest reply on May 29, 2020 by JB1234510

Somehow I'm not able to add all values in a search cursor to a dictionary - one value pair is missing? What is my mistake?

 

def Dict1(self):

        with arcpy.da.SearchCursor(outIntersect, ["FID_Anbinden1", "FLURSTUECKSTEXT"]) as cursor:
            for row in cursor:
                print("{} - {}".format(row[0], row[1]))
                myKey = row[1]
                myValue = row[0]
                myDict[myKey] = myValue
                # myDict.update({myKey: myValue})

        print myDict

This leads to this output (as well as .update in line 9):

1 - 10125
1 - 10079
1 - 10337/2
2 - 10125
{u'10079': 1, u'10337/2': 1, u'10125': 2}

 

u'10125':1 is missing?

Outcomes