Get Count While Applying a filter

Discussion created by cgnadinger on Oct 14, 2011
Latest reply on Oct 14, 2011 by cgnadinger
I hope this is something easy to do, although I can't find the right formula to make this work.

I am trying to run a filter on a table to find features who have a specific field blank. I ultimately want to output that count of features out to a text file. The trouble I am having is that GetCount_management does not work correctly when I try and apply a filter to it.

Right now I have ..

filter = "\"FACILITY_I\" = ' '"
lyr = "C:\\Users\\gisadmin\\Desktop\\TEST\\FH_Test.shp"
result = int(arcpy.GetCount_management(lyr).getOutput(0))
print result 

and that works .. but it's (obviously) giving me the total since the filter is not referenced in at all. When I try and build a filter in I start getting errors, typically Runtime errors in executing tool.

Does someone know how to run this function while applying a filter, or another way to accomplish the same goal?

Also, as opposed to printing the results to a screen I'd like to write them to a table, however I'm moving from vB into Python so I'm still learning the language.

Any advice or help would be greatly appreciated. Thank you!