Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

We want to check if features are empty in the ToolValidator. When you call GetCount_managment() and background processing is on, there is a popup from our validation step. Is there a different method to find if a featureclass is empty, other than using GetCount_management?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

Try a search cursor?

class ToolValidator:

    def __init__(self):
        import arcpy
        self.params = arcpy.GetParameterInfo()

    def initializeParameters(self):
        fc = self.params[0]
        rows = arcpy.SearchCursor(fc)
        if rows.next(): #At least one feature
            #Do something
        else:
            #Do something else
        return
share|improve this answer
    
Thanks. I should have thought of that! I posted the function I used. –  majgis Nov 24 '11 at 0:26
add comment
import arcpy

def isEmpty(table):
    """ Return true if table has no rows."""

    return not arcpy.SearchCursor(table).next()
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.