I would like to search all feature classes in a geodatabase using a search cursor but I want to use two separate where clauses. I'm gathering information about a particular field and I need to know how it is different for each where clause.
The first where clause would be:
GIS_STATUS = 'Superseded'
and the other would be:
GIS_STATUS <> 'Superseded'
My suspicion is that I need to traverse the entire geodatabase twice using two loops. However, I wonder if there a way I can use two simultaneous search cursors? Parallel search cursors?
I'm using ArcGIS Desktop 10.4.1.
There seemed to be a bit of confusion about what I was trying to do, so I'll show what I had in mind.
Firstly, I define two sets. One to hold the values in the METADATA field where GIS_STATUS = 'Superseded'
and another where GIS_STATUS <> 'Superseded'
.
superSet = set()
notSuperSet = set()
Then, I loop through all feature classes twice. One for each where clause:
for dirpath, dirnames, filenames in arcpy.da.Walk(env.workspace, datatype = 'FeatureClass'):
for filename in filenames:
with arcpy.da.SearchCursor(filename, "METADATA", """GIS_STATUS = 'Superseded'""") as sCur:
for row in sCur:
superSet.add(row[0])
and
for dirpath, dirnames, filenames in arcpy.da.Walk(env.workspace, datatype = 'FeatureClass'):
for filename in filenames:
with arcpy.da.SearchCursor(filename, "METADATA", """GIS_STATUS <> 'Superseded'""") as sCur:
for row in sCur:
notSuperSet.add(row[0])
Then, I can use the set methods to determine how they are different.
superSet.difference(notSuperSet)
So, my question is: is this the best way to do this? Do I need two loops?
if
test. Note that there is a difference between "simultaneously open" and "parallel" that can't be realized in a non-threadwd language.