import arcpy,os arcpy.env.overwriteOutput = True targetGdb = arcpy.GetParameterAsText(0) workFolder = os.path.dirname(targetGdb) outFolder = workFolder + os.sep + "CheckforErrors" if not arcpy.Exists(outFolder): arcpy.CreateFolder_management(workFolder, "CheckforErrors") attrErrPt = "AttributionError_Points" attrErrL = "AttributionError_Lines" attrErrP = "AttributionError_Polygons" if not arcpy.Exists(attrErrPt): arcpy.CreateFeatureclass_management(outFolder, attrErrPt, "POINT") if not arcpy.Exists(attrErrL): arcpy.CreateFeatureclass_management(outFolder, attrErrL, "POLYLINE") if not arcpy.Exists(attrErrP): arcpy.CreateFeatureclass_management(outFolder, attrErrP, "POLYGON") outErrPt = outFolder + os.sep + "AttributionError_Points" outErrL = outFolder + os.sep + "AttributionError_Lines" outErrP = outFolder + os.sep + "AttributionError_Polygons" fieldList = ['feattype','idarpt','name','source','ZV7','featsource','imagery','status','idthr','Z5M', 'idstd','tdze','tdzslope','brngtrue','brngmag','rwyslope','tora','toda','asda','lda','vasis', 'cat','thrtype','pntsttyp','marking','lighting','radius','height','material','idp','idrwy','idlin', 'color','style','direc','linsttyp','catstop','gsurftyp','idapron','idbase','ident','surftype','frq', 'station','idhot','jetway','surftype','width','length','idrwi','featbase','bridge','plysttyp'] arcpy.env.workspace = targetGdb datasetList = arcpy.ListDatasets('','feature') for dataset in datasetList: fcs = arcpy.ListFeatureClasses('','', dataset) for fc in fcs: desc = arcpy.Describe(fc) fcType = desc.ShapeType arcpy.AddMessage(fc) arcpy.AddMessage(fcType) if fcType == "Point": fields = arcpy.ListFields(fc) for field in fields: fname = field.name arcpy.AddMessage(field.name) if field.name in fieldList: rows = arcpy.SearchCursor(fc) newRows = arcpy.InsertCursor(outErrPt) row = rows.next() while row: rVal = row.getValue(fname) if rVal == None: newRo = newRows.newRow() newRo.shape = row.shape newRows.insertRow(newRo) row = rows.next() del row, rows, newRows elif fcType == "Polyline": fields = arcpy.ListFields(fc) newRows2 = arcpy.InsertCursor(outErrL) for field in fields: fname = field.name arcpy.AddMessage(field.name) if field.name in fieldList: rows = arcpy.SearchCursor(fc) row = rows.next() while row: rVal = row.getValue(fname) if rVal == None: newRow2 = newRows2.newRow() newRow2.shape = row.shape newRows2.insertRow(newRow2) row = rows.next() del row, rows elif fcType == "Polygon": fields = arcpy.ListFields(fc) newRows3 = arcpy.InsertCursor(outErrP) for field in fields: fname = field.name arcpy.AddMessage(field.name) if field.name in fieldList: rows = arcpy.SearchCursor(fc) row = rows.next() while row: rVal = row.getValue(fname) if rVal == None: newRow3 = newRows3.newRow() newRow3.shape = row.shape newRows3.insertRow(newRow3) row = rows.next() del row, rows
Solved! Go to Solution.
But I have 40+ feature classes and i want only three output error files ( point, line and polygon). how can I use copy features tool here, i believe it would overwrite the out file every time or would create many output files.
I want to know what is causing error in my above script, I tested it and the execution stops exactly at the line where lnsertCursor comes.
I believe it would be a lot less complex to simply create a layer, build a query string off the data using a Search Cursor, and copy the records using the Copy Features tool.
But I have 40+ feature classes and i want only three output error files ( point, line and polygon). how can I use copy features tool here, i believe it would overwrite the out file every time or would create many output files.
I want to know what is causing error in my above script, I tested it and the execution stops exactly at the line where lnsertCursor comes.
You can use the append tool.