AnsweredAssumed Answered

Bypass Nulls or blanks

Question asked by CCweedcontrol on Nov 7, 2018
Latest reply on Nov 7, 2018 by CCweedcontrol

I have the following and i get 'NoneType' object has no attribute 'strip' on line 10. There are some records that have NULL or Blanks in the ACCOUNT field. How do i bypass or skill the ones that are null or blank?

 

 

try:
    #build a dictionary of ACCOUNT : Address pairs
    addDict = {row[0]:row[1] for row in arcpy.da.SearchCursor(fc1,['ACCOUNT','SiteAddress'])}

    #search through fc2 to see if addresses match based on ACCOUNT value
    with arcpy.da.UpdateCursor(fc2, ['Account','SiteAddres','Verifi2']) as cursor:
        for row in cursor:
            if row[1] != None:
                if row[0] in addDict:
                    if row[1].strip().lower()!= addDict[row[0]].strip().lower(): #if the value associated with those ids do not match
                        row[2] = 'No'               
                    else:
                        row[2] = 'Match'
                    cursor.updateRow(row)
    del cursor

Outcomes