Clearly the two highlighted lines in the code (ones with two asterixes around them) taken together should mean that the two circled values in the image must be same. But they are not ! I feel like my head will burst open trying to figure why. Please can some help me?
import arcpy arcpy.env.overwriteOutput = True fc_in = 'E://SUT//Thesis//Geodata//Thesis.gdb//NRW_Gemeinde' fc_in2 = 'E://SUT//Thesis//Geodata//Thesis.gdb//NRWCommuterData2' fc_in3 = 'E://SUT//Thesis//Geodata//Thesis.gdb//NRWGemeindeDissolveFinal_SpatialJoin' dct = {} #Dictionary for gemeinde-workers pair dct2 = {} #Dictionary for gemeinde-value pair dct4 = {} #Dictionary for caseID-result pair lst = [] #List for case IDs fld_gemeinde = 'GEN' fld_workers = 'Workers' fld_result = 'Result' fld_caseID = 'Case_ID_Ne' fld_caseID2 = 'Case_ID' fld_value = 'Value' fld_sub_region_o = 'Sub_Region' fld_sub_region_d = 'Sub_Regi_1' with arcpy.da.SearchCursor(fc_in, (fld_gemeinde, fld_workers), sql_clause=(None, 'ORDER BY "GEN" ASC')) as cursor: for row in cursor: dct[row[0]] = row[1] arcpy.AddField_management(fc_in2, fld_result, 'DOUBLE') with arcpy.da.UpdateCursor(fc_in2, (fld_o, fld_d, fld_caseID, fld_result, fld_value), sql_clause=(None, 'ORDER BY "GEN" ASC')) as cursor2: for row2 in cursor2: if row2[2] in lst: row2[3] = (row2[4] + dct2[row2[2]])/dct[row2[0]] dct2[row2[2]] = row2[4] + dct2[row2[2]] **dct4[row2[2]] = row2[3]** else: row2[3] = row2[4]/dct[row2[0]] lst.extend([row2[2]]) dct2[row2[2]] = row2[4] dct4[row2[2]] = row2[3] cursor2.updateRow(row2) arcpy.AddField_management(fc_in3, fld_result, 'DOUBLE') with arcpy.da.UpdateCursor(fc_in3, (fld_caseID2, fld_result)) as cursor3: for row3 in cursor3: **row3[1] = dct4[row3[0]]** cursor3.updateRow(row3)
أكثر...
import arcpy arcpy.env.overwriteOutput = True fc_in = 'E://SUT//Thesis//Geodata//Thesis.gdb//NRW_Gemeinde' fc_in2 = 'E://SUT//Thesis//Geodata//Thesis.gdb//NRWCommuterData2' fc_in3 = 'E://SUT//Thesis//Geodata//Thesis.gdb//NRWGemeindeDissolveFinal_SpatialJoin' dct = {} #Dictionary for gemeinde-workers pair dct2 = {} #Dictionary for gemeinde-value pair dct4 = {} #Dictionary for caseID-result pair lst = [] #List for case IDs fld_gemeinde = 'GEN' fld_workers = 'Workers' fld_result = 'Result' fld_caseID = 'Case_ID_Ne' fld_caseID2 = 'Case_ID' fld_value = 'Value' fld_sub_region_o = 'Sub_Region' fld_sub_region_d = 'Sub_Regi_1' with arcpy.da.SearchCursor(fc_in, (fld_gemeinde, fld_workers), sql_clause=(None, 'ORDER BY "GEN" ASC')) as cursor: for row in cursor: dct[row[0]] = row[1] arcpy.AddField_management(fc_in2, fld_result, 'DOUBLE') with arcpy.da.UpdateCursor(fc_in2, (fld_o, fld_d, fld_caseID, fld_result, fld_value), sql_clause=(None, 'ORDER BY "GEN" ASC')) as cursor2: for row2 in cursor2: if row2[2] in lst: row2[3] = (row2[4] + dct2[row2[2]])/dct[row2[0]] dct2[row2[2]] = row2[4] + dct2[row2[2]] **dct4[row2[2]] = row2[3]** else: row2[3] = row2[4]/dct[row2[0]] lst.extend([row2[2]]) dct2[row2[2]] = row2[4] dct4[row2[2]] = row2[3] cursor2.updateRow(row2) arcpy.AddField_management(fc_in3, fld_result, 'DOUBLE') with arcpy.da.UpdateCursor(fc_in3, (fld_caseID2, fld_result)) as cursor3: for row3 in cursor3: **row3[1] = dct4[row3[0]]** cursor3.updateRow(row3)

أكثر...