I am using arcpy.CalculateField_management to fill a column field with another column values.
I have two shapefiles, fishnet.shp and new_run.shp. First I joined both using arcpy.AddJoin_management as follows:
arcpy.MakeFeatureLayer_management("fishnet.shp","fishnet_layer")
arcpy.AddJoin_management("fishnet_layer","FID","new_run_grid.shp","FID_fishne")
Now I want to assign fishnet.shp's column rungrid the value of the joined table's column final_run value.
How to use arcpy.CalculateField_management here?
I tried the following code but it gave error:
arcpy.CalculateField_management("fishnet_layer","rungrid","!new_run.final_run","PYTHON")
I am getting the following error:
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000728: Field rungrid does not exist within table
Failed to execute (CalculateField).
Further
I checked the names of the fields of fishnet_layer and these two names are there fishnet.run_grid and new_run.final_run. After giving the following command:
arcpy.CalculateField_management("fishnet_layer",'fishnet_f.run_grid','new_run_grid.run_grid1',"PYTHON")
I am getting the following error:
ExecuteError: ERROR 000539: Error running expression: new_run_grid.run_grid1
Traceback (most recent call last):
File "<expression>", line 1, in <module>
NameError: name 'new_run_grid' is not defined
Failed to execute (CalculateField).
print [f.name for f in arcpy.ListFields("fishnet_layer")]after join. Maybe you are using the wrong names in Calculate Fieldnew_run_grid.shpand use this in the join. You cant join a shapefile to a layer, both need to be layers