The values entered are returned. I entered 1 for RMS and F for Classification.
The initial whereClause runs fine, until a null value is encountered. I believe the issue is still with the UpdateCursor. I have gone back and attempted to work with the previous suggestions, but to not avail. The results are still the same, no errors, and no results. I know how to fix the null vs blank problem using field calculator, but not with a script. Other suggestions?
import arcpy RMS = arcpy.GetParameterAsText(0) Classification = arcpy.GetParameterAsText(1) mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] fc = arcpy.mapping.ListLayers(mxd, "Region", df)[0] arcpy.AddMessage(str(RMS)) arcpy.AddMessage(str(Classification)) #Logic try: whereClause = ''' "RMS" = '{0}' AND "Classification" = '{1}' '''.format(RMS, Classification) arcpy.SelectLayerByAttribute_management(fc, "NEW_SELECTION", whereClause) df.extent = fc.getSelectedExtent() df.scale = df.scale*1.1 arcpy.SelectLayerByAttribute_management(fc, "CLEAR_SELECTION", whereClause) sql = "{0}".format(arcpy.AddFieldDelimiters(Region, RMS, Classification)) + " IS NULL" # not sure what the output of this is,is it valid sql? in either case, Region variable is not defined cursor = arcpy.da.UpdateCursor(fc, "RMS", sql) # the region layer has been set to variable fc. for row in cursor: row[0] = "" cursor.updateRow(row) del row, cursor except: print arcpy.GetMessages()
If it were me, I'd make a copy of my data and try to get the updateCursor working WITHOUT the where clause ( cursor = arcpy.da.UpdateCursor(fc, "RMS") ).run it with row[0] = "test"then with row[0] = "" # of course, all this assumes the "Region" field is a text field...Once you get it working for ALL rows in the table, then I'd figure out the proper where clause to put in there.A lot of time, select/copy/paste each line in the IDLE window and running it will often give an idea of what is going wrong. Also, in the IDLE, you can type "print variable" (I.e. >>>print RMS ) at any time to see the value that is currently assigned to it. Also "type(variable)" will give you the variable type to ensure it is the proper input for a tool.On another note, you said you could calculate it, but want to do it with python, why not:arcpy.CalculateField_management(fc, "RMS", "\\"", "PYTHON_9.3")
Also, your selectLayerbyAttributes is putting a selection on the fc before the cursor. Documentation for UdateCursor doesn't say if it honors selections or not, but you might try to clear selection before the updatecursor.R_