How to add attributes in Feature class using Arcpy

المشرف العام

Administrator
طاقم الإدارة
I have a geodatabase with multiple Feature Class (at least 100).

I would like to add in each attribute table of each Feature Class, two new columns. I have to do that with a python script because it would be very long to add the columns one by one.The two new columns are : "symbole" and "deslotID".

I try to make a python script, but I don't know anything about python.This is the code (I know it don't works)

>>> import arcpyfrom arcpy import env#My environment and the geodatabase that contains the feature classenv.workspace = "C:/data/arcgis/gdb/Featureclass.gdb"#Set fieldname variables = 2 new columnsfield_name1 = "symbole"field_name2 = "deslotID"#Define the fields's structurefields = [("featureclass", "field_name1", "LONG", 9, "", "", "refcode", "NULLABLE", "NON_REQUIRED")("featureclass", "field_name2", "INT", 9, "", "", "refcode", "NULLABLE", "NON_REQUIRED")]for field in fields: arcpy.AddField_management(*(featureclass,) + field)For this code, I was inspired by this question : Possible to add multiple fields in single arcpy statement?

I think I have to make a loop that runs through all the feature class in the geodatabase, I really don't know how to do that.



أكثر...
 
أعلى