AnsweredAssumed Answered

how to execute an python arcsript

Question asked by helenak on Jul 11, 2012
Latest reply on Sep 22, 2012 by helenak
System: ArcGIS 9.3

Problem

I want to use a code to split rows using a script downloaded from arcscript. (attached)
However, an error message showed that

"AttributeError: Object: Tool or environment <SplitByAttribute> not found"

Please kindly advise modification on the following code and thank you.

##Script Name: split rows ##Description: using  ##Created By: Elaine Kuo ##Date: 12/07/2012   #Import standard library modules import arcgisscripting import os  #Create the Geoprocessor object gp = arcgisscripting.create(9.3)   #Set the workspace. gp.Workspace= "H:/temp/test"   #Set the workspace. List all of the feature classes in the dataset outWorkspace= "H:/temp"  # Add a toolbox with a model to the geoprocessor and set the workspace gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolBox/Toolboxes/Split rows.tbx")   #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            #Validate the new feature class name for the output workspace.     OutFeatureClass = outWorkspace + os.sep + gp.ValidateTableName(fc,outWorkspace)      #get file name     fcName, fcExt = os.path.splitext(fc)       #build field name     fieldName = fcName      #### Execute Script Tool ####     gp.SplitByAttribute(fc, fieldName, outWorkspace, fieldName)     gp.AddMessage(gp.GetMessages()) print gp.GetMessages()                            

Attachments

Outcomes