我目前正在尝试填充 2 个字段。它们都已经在我想用现有要素类中的数据填充的表中创建。这个想法是从与特定项目#匹配的所需要素类中复制所有数据。与项目 # 匹配的行将复制到具有匹配字段的空白模板。到目前为止,一切都很好,除了我需要将来自 OBJECT ID 字段和要素类名称的数据推送到表中的 2 个字段中。
**def featureClassName(table_path):
arcpy.AddMessage("Calculating Feature Class Name...")
print "Calculating Feature Class Name..."
featureClass = "FeatureClass"
SDE_ID = "SDE_ID"
fc_desc = arcpy.Describe(table_path)
lists = arcpy.ListFields(table_path)
print lists
with arcpy.da.SearchCursor(table_path, featureClass = "\"NAME\"" + " Is NULL") as cursor:
for row in cursor:
print row
if row.FEATURECLASS = str.replace(row.FEATURECLASS, "*", fc):
cursor.updateRow(row)
print row
del cursor, row
else:
pass**
上面的代码是我尝试使用要素类的名称填充字段的众多方法。我试图对 OID 做同样的事情。
**for fc in fcs:
print fc
if fc:
print "Making Layer..."
lyr = arcpy.MakeFeatureLayer_management (fc, r"in_memory\temp", whereClause)
fcCount = int(arcpy.GetCount_management(lyr).getOutput(0))
print fcCount
if fcCount > 0:
tbl = arcpy.CopyRows_management(lyr, r"in_memory\temp2")
arcpy.AddMessage("Checking for Feature Class Name...")
arcpy.AddMessage("Appending...")
print "Appending..."
arcpy.Append_management(tbl, table_path, "NO_TEST")
print "Checking for Feature Class Name..."
featureClassName(table_path)
del fc, tbl, lyr, fcCount
arcpy.Delete_management(r"in_memory\temp")
arcpy.Delete_management(r"in_memory\temp2")
else:
arcpy.AddMessage("Pass... " + fc)
print ("Pass... " + fc)
del fc, lyr, fcCount
arcpy.Delete_management(r"in_memory\temp")
pass**
此代码是数据集中要素类的主循环,我创建了一个新图层/表以用于将数据复制到表中。要素类名称和 OID 的数据没有要推送的数据,所以这就是我卡住的地方。
谢谢大家