How do you check if a feature class is empty and if it's empty append features to that feature class, if it's not not empty it would just pass or ignore the append. Would it best to use count or arcpy.da.SearchCursor?
with arcpy.da.SearchCursor(FcLyr, "SHAPE@")as cursor: for row in cursor: if row is None: arcpy.Append_management(FcLyr2, FcLyr) else: print 'Has features'
Solved! Go to Solution.
So i tried two different approaches. I am not sure which one is correct but they seem to be working.
Do these seem like reasonable approaches?
result = arcpy.GetCount_management(FcLyr) count = int(result.getOutput(0)) print(count) if count == 0: arcpy.Append_management(FcLyr2, FcLyr) print "Layer empty, appending features " + FcLyr else: print "layer has features " + FcLyr
Count = int(arcpy.GetCount_management(FcLyr).getOutput(0)) if Count > 0: print("Lyr has features") else: arcpy.Append_management(FcLyr2, FcLyr) print("Lyr append completed successfully")