AnsweredAssumed Answered

What sorcery is this?

Question asked by salmanseahmed on Jun 23, 2015
Latest reply on Jun 24, 2015 by salmanseahmed

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

dct3 = {} #Dictionary for gemeined-result pair

dct4 = {} #Dictionary for caseID-result pair

dct5 = {} #Dictionary for sub-region origin and destination pair

dct6 = {} #Dictionary for case_ID and result pair

lst = [] #List for case IDs


fld_gemeinde = 'GEN'

fld_workers = 'Workers'

fld_result = 'Result'

fld_o = 'GEN'

fld_d = 'GEN_1'

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]


            row2[3] = row2[4]/dct[row2[0]]


            dct2[row2[2]] = row2[4]

            dct4[row2[2]] = row2[3]



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]]



Clearly the two lines in the code in bold means that the two circled values in the image should be same. But they are not ! I feel like my head will burst open trying to figure why. Please can some help me?