AnsweredAssumed Answered

Use variable for field name in search cursor

Question asked by leftieant76 on Aug 21, 2012
Latest reply on Aug 21, 2012 by leftieant76
Firstly, apologies for grammar and spelling, I am typing one handed and nursing a baby with the other.

I am looking for a way to use a variable as a field name for a search cursor, with the variable being drawn from another search cursor that runs down a dbf table.

The context is that the dbf table contains a list of themes that need to be queried, and also a list of fields in those themes that need to be reported.

I hope to pluck out the field names that need to be reported on and apply these to the search cursor running down the theme.

Any thoughts? I am currently using arcpy.getValue but it does not seem to be working.

Code snippet below:

if int(theme.REPFLD_NUM) == 0:                             pass                         elif int(theme.REPFLD_NUM) == 1:                             repfld1 = str(theme.getValue("REPFLD_1"))                             output_text.write(seltheme.repfld1 + "\n")                             del repfld1                         elif int(theme.REPFLD_NUM) == 2:                             repfld1 = str(theme.getValue("REPFLD_1"))                             repfld2 = str(theme.getValue("REPFLD_2"))                             output_text.write(seltheme.repfld1 + " - " + seltheme.repfld2 + "\n")                             del repfld1, repfld2  and so on.


Would appreciate any suggestions.

Outcomes