Hello, I am trying to create a script that allows making a loop inside the data set, using each layer inside it to create a specific report, my question is how can I make the name of the output resulting layer as it matches the name of the input layer like %Name% in model builder. the following is the script.
import arcpy
... arcpy.env.workspace=r'E:\Drawing_id\drawing.gdb'
... listdataset=arcpy.ListDatasets("*","feature")
... listfeature=arcpy.ListFeatureClasses("*","",listdataset)
... for ds in listdataset:
... if ds =='potablwater':
... listfeature=arcpy.ListFeatureClasses("*","",ds)
... for fc in listfeature:
... listfield=arcpy.ListFields(fc)
... for fd in listfield:
... if 'DRAWINGID' in fd.name:
... arcpy.Frequency_analysis(fc,r'C:\Users\aaaaa\Documents\ArcGIS\Default.gdb\??????','DRAWINGID')
thanks
Look into the topic of string concatenation. Plenty of examples on the internet.
import os
... (snip)
for fc in listfeature:
listfield=arcpy.ListFields(fc, 'DRAWINGID')
if listfield:
out_tbl = os.path.join(r'C:\Users\aaaaa\Documents\ArcGIS\Default.gdb',
"{}_tbl".format(fc))
arcpy.Frequency_analysis(fc, out_tbl, 'DRAWINGID')