for row in arcpy.SearchCursor("TESTFC") print row.TestField1
Solved! Go to Solution.
import arcpy #Create a table in memory to hold the codes and their descriptions for a particular domain. cvdTable = arcpy.DomainToTable_management(r'C:\vancouver.gdb', 'type', 'in_memory/cvdTable', 'codeField', 'descriptionField') #Create an empty dictionary. d = {} #Create a cursor to loop through the table holding the domain and code info rows = arcpy.SearchCursor(cvdTable) # Loop through each row in the table. for row in rows: # For each row in the table populate the key with the code field and the value from the description field d[row.codeField] = row.descriptionField #Cleanup del row del rows # Create a search cursor on the table with the domain rows2 = arcpy.SearchCursor(r'C:\vancouver.gdb\TESTFC') # Loop through the records in the table. for row2 in rows2: # Print the dictionary value for each code that is returned from this search cursor print d[row2.PipeType] #Cleanup del row del rows
import arcpy #Create a table in memory to hold the codes and their descriptions for a particular domain. cvdTable = arcpy.DomainToTable_management(r'C:\vancouver.gdb', 'type', 'in_memory/cvdTable', 'codeField', 'descriptionField') #Create an empty dictionary. d = {} #Create a cursor to loop through the table holding the domain and code info rows = arcpy.SearchCursor(cvdTable) # Loop through each row in the table. for row in rows: # For each row in the table populate the key with the code field and the value from the description field d[row.codeField] = row.descriptionField #Cleanup del row del rows # Create a search cursor on the table with the domain rows2 = arcpy.SearchCursor(r'C:\vancouver.gdb\TESTFC') # Loop through the records in the table. for row2 in rows2: # Print the dictionary value for each code that is returned from this search cursor print d[row2.PipeType] #Cleanup del row del rows
Just adding this here because this was the top hit in Google for my first search on the same topic
You can leverage environment settings to do this now instead of the dictionary repeat