import arcpy import os, math from arcpy import env in_workspace = r"F:/test/testRnd" rndValue = "int(round(!ELEVATION!, -2))" fcList = [] fieldName = "SL_ELEV" for dirpath, dirnames, filenames in arcpy.da.Walk(in_workspace, datatype="FeatureClass",type="All"): for filename in filenames: fcList.append(os.path.join(dirpath, filename)) #Add new field arcpy.AddField_management(fcList, fieldName, "SHORT", "", "", "", "", "NULLABLE")
Solved! Go to Solution.
I am trying to add a field to all layers with multiple GDB's. Am I unable to collect a list of values and run addField tool on them?import arcpy import os, math from arcpy import env in_workspace = r"F:/test/testRnd" rndValue = "int(round(!ELEVATION!, -2))" fcList = [] fieldName = "SL_ELEV" for dirpath, dirnames, filenames in arcpy.da.Walk(in_workspace, datatype="FeatureClass",type="All"): for filename in filenames: fcList.append(os.path.join(dirpath, filename)) #Add new field arcpy.AddField_management(fcList, fieldName, "SHORT", "", "", "", "", "NULLABLE")
Thanks
for dirpath, dirnames, filenames in arcpy.da.Walk(in_workspace, datatype="FeatureClass",type="All"): for filename in filenames: fcList.append(os.path.join(dirpath, filename)) for list in fcList: arcpy.AddField_management(list, fieldName, "SHORT", "", "", "", "", "NULLABLE")
I am trying to add a field to all layers with multiple GDB's. Am I unable to collect a list of values and run addField tool on them?import arcpy import os, math from arcpy import env in_workspace = r"F:/test/testRnd" rndValue = "int(round(!ELEVATION!, -2))" fcList = [] fieldName = "SL_ELEV" for dirpath, dirnames, filenames in arcpy.da.Walk(in_workspace, datatype="FeatureClass",type="All"): for filename in filenames: fcList.append(os.path.join(dirpath, filename)) #Add new field arcpy.AddField_management(fcList, fieldName, "SHORT", "", "", "", "", "NULLABLE")
Thanks
for dirpath, dirnames, filenames in arcpy.da.Walk(in_workspace, datatype="FeatureClass",type="All"): for filename in filenames: fcList.append(os.path.join(dirpath, filename)) for list in fcList: arcpy.AddField_management(list, fieldName, "SHORT", "", "", "", "", "NULLABLE")