I have a handful of approximately 1000 shapefiles that are corrupted (see attached error message). The shapefiles were generated from eCognition Developer 8. There is a script tool that seems to repair the shapefile once it is identified as corrupted.
I want to create a quick script to loop through all of my shapefiles and check if the number of shapes matches the table records. I can count table records using the following:
# Name: fcCount.py # Purpose: calculate the number of features in a featureclass # Import system modules import arcpy from arcpy import env env.workspace = "C:/data" Sample = "MyShp.shp" result_dbf = int(arcpy.GetCount_management(Sample).getOutput(0)) print result_dbf
I would ultimately like to create some sort of logic check such as:
if result_dbf = result_shp: pass else: print "There is a problem with" + str(Sample)
How can I count shapes directly without accessing the .dbf file? Or, in other words, what is the best way to programmatically check if the number of shapes matches the number of table records?