# Create dictionary with segmentid as key, calculated length as value1, measured length as value2 fiberCableLengths = defaultdict(list) with arcpy.da.SearchCursor(fiberCable, ['segmentid', 'calculatedlength', 'measuredlength']) as cursor: for row in cursor: fiberCableLengths[row[0]].append(row[1]) fiberCableLengths[row[0]].append(row[2]) # Create slackloop dictionary with segmentidfkey as key, total up the length values of each slackloop under that segmentidfkey, and store as the dictionary value slackloopLengths = defaultdict(list) with arcpy.da.SearchCursor(slackLoop, ['segmentidfkey', 'length']) as cursor: for row in cursor: if row[1] is not None: slackloopLengths[row[0]].append(int(row[1])) sumValueDict = {k: sum(v) for k, v in slackloopLengths.items()} # For each fibercable segmentid in dictionary, If calculated length + total slackloop length = measured length – Add to good list, Else – Add to bad list goodList = [] badList = [] with arcpy.da.SearchCursor(fiberCable, ['segmentid', 'calculatedlength', 'measuredlength']) as cursor: for row in cursor: for k, v in sumValueDict.items(): if row[0] == k: if row[1] and row[2] is not None: if int(row[1]) + slackloopLengths[1]int(v) == int(row[2]): goodList.append[row[1]]append(str(row[0])) print "Good List: " + row[0] print int(row[1]) + int(v) print int(row[2]) else: badList.append[row[1]]append(str(row[0])) print "Bad List: " + row[0] print int(row[1]) + int(v) print int(row[2]) print "Good List Size: " + str(len(goodList)) print "Bad List Size: " + str(len(badList))
Became Hot Network Question