AnsweredAssumed Answered

OutFeatureClass does not work in SelectLayerByAttribute

Question asked by helenak on May 7, 2012
Latest reply on May 10, 2012 by helenak
System 9.3
pythonWin 2.5

Problem:
Using OutFeatureClass in the code below, but the output featureclass was not found in the outworkplace.

Please kindly help and thanks.

##Script Name: Delete rows ##Description: delete selected rows ##Created By: Elaine Kuo ##Date: 08/05/2012  #Import standard library modules import arcgisscripting import os  #Create the Geoprocessor object gp = arcgisscripting.create(9.3)  #Set the input workspace #GP.workspace = sys.argv[1] #Set the workspace. gp.Workspace= "G:/temp"  #Set the output workspace #outWorkspace = sys.argv[2] #Set the workspace. List all of the feature classes in the dataset outWorkspace= "G:/temp/test"  #Get a list of the featureclasses in the input folder fcs = gp.ListFeatureClasses()  # Loop through every item in the list that was just generated for fc in fcs:      # Break out the name, no path or extension, using the describe object.     desc = gp.describe(fc)     featureName = desc.name      # Make featureclasses as layers     gp.OverWriteOutput = 1     gp.toolbox = "Data Management"     gp.MakeFeatureLayer("geor0313_p.shp","geor0313_p_lyr")          #Get a list of the fields in the featureclass     fields = gp.ListFields("geor0313_p_lyr", "C*", "String")      # Loop through every item in the list that was just generated      for field in fields:          gp.toolbox = "Data Management"         gp.addMessage(type(field))         # Select records to be deleted (C*, i.e. C7658)         query = "\"%s\" = 'R'" % field.Name         gp.SelectLayerByAttribute("geor0313_p_lyr", "ADD_TO_SELECTION", query)          # Delete selected records         gp.DeleteRows("geor0313_p_lyr")              #Validate the new feature class name for the output workspace.     outFeatureClass = outWorkspace + os.sep +gp.ValidateTableName("geor0313_p_lyr",outWorkspace)

Outcomes