Select to view content in your preferred language

Add field: error in executing tool

719
1
Jump to solution
06-06-2013 09:19 AM
ChrisBrannin
Occasional Contributor
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
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ChrisBrannin
Occasional Contributor
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


I just needed to run another loop. This got it.

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")

View solution in original post

0 Kudos
1 Reply
ChrisBrannin
Occasional Contributor
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


I just needed to run another loop. This got it.

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")
0 Kudos