1、
mdbs = arcpy.ListWorkspaces("*","Access")
2、
FeatureClasses = arcpy.ListFeatureClasses()
3、
Fields = arcpy.ListFields(FeatureClass)
4、
cursor = arcpy.da.SearchCursor(FeatureClass, ‘ELEV‘)
注意:工作空间的转换
import arcpy from arcpy import env import os #input = r"E:\test\MDB" input = arcpy.GetParameterAsText(0) env.workspace = input mdbs = arcpy.ListWorkspaces("*","Access") for mdb in mdbs: #a = "" cout = 0 mdbname = mdb[-14:-4] #print mdbname env.workspace=mdb FeatureClasses = arcpy.ListFeatureClasses() for FeatureClass in FeatureClasses: if "TERP" in FeatureClass: #print FeatureClass Fields = arcpy.ListFields(FeatureClass) for Field in Fields: fieldname = Field.name #print fieldname if "ELEV" in fieldname: cursor = arcpy.da.SearchCursor(FeatureClass, ‘ELEV‘) for row in cursor: #print(row) if row[0] == 0: #a = mdbname cout = cout+1 if cout > 0: arcpy.AddMessage(mdbname+" "+"dgx Elev have 0 problem!") textpath = input+os.sep+"text.txt" f = open(textpath,"a") f.write(mdbname+‘\n‘) f.close() # print cout # f = open("E:/test/text.txt","a") #f.write(a+‘\n‘) #f.close()
原文地址:https://www.cnblogs.com/gistwz/p/10265676.html
时间: 2024-10-07 02:20:37