Quantcast
Channel: Question and Answer » arcmap
Viewing all articles
Browse latest Browse all 248

How to Calculate Field in joined table using ArcPy?

$
0
0

I have to calculate a field based on another field in a joined table, but an error occurs:

“Parameters are not valid.
ERROR 000728: Field !Table_A.field_A! does not exist within table”

My code:

import arcpy
from arcpy import env
env.workspace = "C:/TMP/BASELINE.gdb"
Table_A = "dist"
Table_B= "matrix"
arcpy.AddJoin_management(Table_A, "id_grid", Table_B, "id_matrix")
arcpy.CalculateField_management(Table_A, "!" + Table_A + ".field_A!", "!" + Table_B + ".field_B!","PYTHON")

Both tables are in the BASELINE.gdb. The Join occurs without any problem.

I forgot to say that, of course, “field_A” exists in “Table_A” and “field_B” exists in “Table_B”.

Last but not least, if I run the same calculation in ArcMap, using Field Calculator, no error occurs.


Viewing all articles
Browse latest Browse all 248

Trending Articles