AnsweredAssumed Answered

how to debug a python code for ArcGIS 10

Question asked by helenak on Sep 22, 2012
Latest reply on Sep 24, 2012 by m.gasior
Hello

System ArcGIS 10
Windows XP

I ran a code below but it said that there was invalid syntax.
I did not know where the error was.

Please kindly help and thank you.

#Name: split_row_0924.py #Description:Split rows by attributes  #Import system modules import arcpy from arcpy import env  import os   #Set the workspace. arcpy.env.workspace= "H:/temp/test1"   #Set the workspace. List all of the feature classes in the dataset outWorkspace= "H:/temp/test1"  #Add a toolbox with a model to the geoprocessor and set the workspace gp.AddToolbox("H:/temp/test1/SplitLayerByAttributes.tbx")   #Get a list of the featureclasses in the input folder fcs = arcpy.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 = arcpy.describe(fc)     featureName = desc.name            #Validate the new feature class name for the output workspace.     OutFeatureClass = outWorkspace + os.sep + arcpy.ValidateTableName(fc,outWorkspace)      #get file name     fcName, fcExt = os.path.splitext(fc)       # replace the strings you want to     #fcName = fcName.replace("_Dissolve","")      #build field name     #fieldName = fcName      #fcName = fcName + fcExt      # rename the files     #gp.Rename_management(fc, fcName)        #build field name     fieldName = fcName      #### Execute Script Tool ####     arcpy.SplitLayerByAttributes(fc, fieldName, OutFeatureClass, outWorkspace)     except Exception, e:     # If an error occurred, print line number and error message     import traceback, sys     tb = sys.exc_info()[2]     print "Line %i" % tb.tb_lineno     print e.message                            

Outcomes