Requierd Python Help

668
1
03-25-2014 02:58 AM
H_A_D_Padmasiri
New Contributor
Dear sir

I want to update TextString field in "PCL_Anno_New" annotation feature class in a geodatabase. For that I join "Conv_Tab" and try to update. it gives Following error. Can you give me help to correct it?

Thanks
Tags (2)
0 Kudos
1 Reply
by Anonymous User
Not applicable
Unfortunately I do not think cursors will work on joined tables.  I think you would be better off using a dictionary with an update cursor.  This code is untested but something like this should work:

import arcpy

# tables
source_tab = r"E:\Gampaha\51027202\CM51027202.gdb\CM51027202\PCL_Anno_New"
read_tab = r"C:\CMSupport.gdb\Conv_Tab"

# Create dictionary for update cursor
rows = arcpy.SearchCursor(read_tab)
cur_dict = dict((r.Nam_Idm, r.Name_Sin) for r in rows if r.Name_Sin)
del rows

# Update cursor to fill in rows
cur = arcpy.UpdateCursor(source_tab)
for row in cur:
    if row.Text in cur_dict:
        row.TextString = cur_dict[row.Text]
        cur.updateRow(row)
del cur, row
0 Kudos