AnsweredAssumed Answered

create variable counter name from string functions and then auto-increment in loop

Question asked by dedge on Feb 13, 2013
Latest reply on Feb 19, 2013 by scavey
Greetings All

hopefully the subject makes sense and if not, here's a longer version:
I have about 350 mdbs in various folders that have the same schemas and has data captured over 2 years.

due to some reporting errors that have now come to light, i need to do a count/append on all the features and report on any discrepanies.

i used the os.walk function to find all the mdbs and then used a check to make sure the source feature class had some features (getcount) and that it matched my blank target checking mdb. if it matched, it appends the data and moves on.

i used a string variable to hold the master list of feature class names:
"defects,photos,building,etc"
to check the source feature class existence, i used a simple string.find(fc, masterlist) != 1

while its easy to create a simple counter to return total number of records written, what i really want to do is have several counters, one for each feature class. and the counter gets called and incremented only when it encounters one of the feature classes with valid features.
Like: defects_count, photos_count, building_count etc

while its easy to build the variable name using string functions (varcounter = fc + "_count") I dont see how i could keep incrementing the number of features found using varcounter = varcounter + countfc.

is python smart enough to figure out that the string i created in a variable is actually another number variable?

Apologies for the long post

thanks in advance

Outcomes