AnsweredAssumed Answered

Printing Field name Using Search Cursor on a Joined Field

Question asked by BrokenLegMike on Feb 6, 2012
Latest reply on Feb 6, 2012 by BrokenLegMike
Hello,

I am trying to print out the values in a field using a cursor search on a field which I have have joined.

I have created a field list and printed it, and i get all the indexed field names, (i.e. SO_SOIL_P.SITE) which is great, but when I try to use the field name when I print the row's value in a cursor search, it's telling me the field doesn't exist. I think it's the processor is having troubles handling the 2 periods in the field ID for the row (i.e. row.SO_SOIL_P.SITE), but it also doesn't like row.SITE. Can anyone suggest a way to write this line to have the values returned properly? Please see the comments at the bottom of the script.

Thanks,
Mike

Code:
import arcpy from arcpy import env  env.overwriteOutput = True  # Local variables: SOIL_P_TERR_Spatial = "Z:\\ESRI\\Geodatabase\\Test1.gdb\\SOIL_P_TERR_Spatial" SO_SOILSCHEM_T = "Z:\\ESRI\\Geodatabase\\Test1.gdb\\SO_SOILSCHEM_T" SO_SOIL_P = "Z:\\ESRI\\Geodatabase\\Test1.gdb\\SO_SOIL_P" v_smu = "\"smu\"" v_spatial_ = "\"spatial\"" soiltable = "soiltable" v_smu2 = "\"smu\""   arcpy.AddIndex_management(SO_SOIL_P, "SITE;SITE_ID;LOCATION;LSD", "SO_SOIL_P_index", "NON_UNIQUE", "ASCENDING")  # Process: Make Feature Layer arcpy.MakeFeatureLayer_management(SO_SOIL_P, v_smu)  # Process: Add Join arcpy.AddJoin_management(v_smu, "SITE_ID", v_spatial_, "SITE_ID", "KEEP_ALL")  # Process: Make Table View arcpy.MakeTableView_management(SO_SOILSCHEM_T, soiltable)  # Process: Add Join (2) jointables = arcpy.AddJoin_management(v_smu2, "SO_SOIL_P.SITE_ID", soiltable, "SITE_ID", "KEEP_ALL")    fieldList = arcpy.ListFields(jointables)  # This prints all the fields in the above joins successfully. for field in fieldList:     print field.name        rows = arcpy.SearchCursor(jointables)  for row in rows:      # This will print the unicode row      print row      # This print will error out, saying the field doesn't exist, but in the field list about, it does      print row.SO_SOIL_P.OBJECTID      # I get the same error when I try this as well      print row.OBJECTID

Outcomes