I am trying to add a Python script in a toolbox to discover the number of records of some shp files stored in a folder.

I wonder that the script works pretty good as stand-alone in the Python command line of ArcMap; but it returns an error when imported in a toolbox. From the stand-alone script I changed only the workspace as arcpy.GetParameterAsText(0).

I am aware that the point should be somehow WHERE to print the results (I learned in the geoprocessing results(?)), as there is no command line; and I also tried to use AddMessage instruction instead of 'print', but unsuccessfully. This is the script imported in the toolbox:

>>> import arcpy
#define workspace
arcpy.env.workspace = arcpy.GetParameterAsText(0)
#create a list of objects to loop through
FC = arcpy.ListFeatureClasses()
#loop throw every object
for SingleFC in FC:
#call function
 count = arcpy.GetCount_management(SingleFC)
#print results
 print('{} has {} records'.format(SingleFC, count[0]))
  • 2
    Try count = arcpy.GetCount_management(SingleFC).getOutput(0))
    – Bera
    Commented Oct 17, 2019 at 10:27
  • Thanks BERA, still it's not correct....
    – Miche
    Commented Oct 18, 2019 at 14:19


Browse other questions tagged or ask your own question.