AnsweredAssumed Answered

if attributes exists

Question asked by Tonyalmeida on Dec 10, 2013
Latest reply on Dec 10, 2013 by Wayne_Whitley
I have the following code that work good, but i would like my script to check if there is text(string) in the FacltyType field on Points_1 if it does i would like the script to skip that feature, but if it does not i would like the script to run.

Any help would be great.

import arcpy, time arcpy.env.overwriteOutput = True  arcpy.env.workspace = r"C:\Temp\Default.gdb" fcTarget = 'Points_1' fcJoin = 'Points_2' fcOutput = 'Points_joined'  arcpy.SpatialJoin_analysis(fcTarget, fcJoin, fcOutput, 'JOIN_ONE_TO_ONE', 'KEEP_COMMON')  curR = arcpy.SearchCursor(fcOutput, '', '', '', 'AddressID A') curW = arcpy.UpdateCursor(fcTarget, '', '', '', 'AddressID A')  # init rowW and rowR rowW = curW.next() rowR = curR.next()  while rowR:     currentAddress = rowR.AddressID     print 'current add: ' + currentAddress     while rowW.AddressID != currentAddress:         rowW = curW.next()      if not rowR.SiteNum == rowR.SiteNum_2:         rowW.FacltyType = 'ERROR'         rowR = curR.next()      elif rowR.FacltyType == ' ' and rowR.CPUC == ' ':          rowW.FacltyType = 'MobileHome'                   rowW.APA_CODE = '1150'          rowW.StructType = 'Primary, Private'          rowW.Verified = 'Yes, GRM, TA, ' + time.strftime('%m/%d/%Y')          rowW.Status = 'Active'          rowW.StructCat = 'Residential'         # etc., etc., fill in the rest     elif rowR.FacltyType == ' ' and 'DWELL' in rowR.CPUC:          rowW.FacltyType = 'Single Family Home'          rowW.APA_CODE = '1110'          rowW.StructType = 'Primary, Private'          rowW.Verified = 'Yes, GRM, TA, ' + time.strftime('%m/%d/%Y')          rowW.Status = 'Active'          rowW.StructCat = 'Residential'          # etc., etc., fill in the res     else:          rowW.FacltyType = rowR.CPUC          rowW.StructType = 'Primary, Private'          rowW.Verified = 'Yes, GRM, TA, ' + time.strftime('%m/%d/%Y')          rowW.Status = 'Active'          # etc., etc., fill in the rest                  curW.updateRow(rowW)     rowR = curR.next() # changed the delete statement, targeting the cursor objs (rather than the row objs) if curW:     del curW if curR:     del curR  arcpy.RefreshActiveView() arcpy.RefreshTOC() 

Outcomes