Select to view content in your preferred language

Excluding features from a feature list

1352
4
02-09-2012 10:22 PM
MichaelBarker
Occasional Contributor
I've written a script that will create a list of all the feature classes in a geodatabase then have it run an analyze on each, writing out the result to a log file so I know what's been done.  Problem I am having is I would like to not have analyze work on sde views, as it causes the script to fail.  The views always have VW within the name e.g. WA_Her_Svy_vw_Test so they can be isolated from the rest.  Main part of the code below.
Any help would be much appreciated.
Thanks in advance, Mike.

features = arcpy.ListFeatureClasses()
    for fc in features:
        arcpy.Analyze_management(fc, "BUSINESS")
        now = datetime.datetime.now()
        analyzeLog.write(fc + " Analyzed at: " + now.strftime("%H:%M:%S") + '\n')
Tags (2)
0 Kudos
4 Replies
MarcinGasior
Frequent Contributor
ListFeatureClasses() has optional parameters:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v0000001n000000

So you can add "*_vw_*" as a wild_card or specify geometry type.
0 Kudos
MichaelBarker
Occasional Contributor
Using the wildcard parameter in list features will select only the feature classes like *vw* what I wanted to do was list features except *vw* or exclude from the list once it is created feature classes like *vw*.
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Michael,

You could append all feature classes to a list, and then analyze all feature classes that do not contain 'vw'.  Ex:

list = []
lstFCs = arcpy.ListFeatureClasses()
for fc in lstFCs:
    list.append(fc)

for n in list:
    if "vw" not in n:
        arcpy.Analyze_management(n, "BUSINESS")
        now = datetime.datetime.now()
        analyzeLog.write(n + " Analyzed at: " + now.strftime("%H:%M:%S") + '\n')
0 Kudos
MichaelBarker
Occasional Contributor
Thanks that worked perfectly.
0 Kudos