copy joined field

785
4
02-13-2011 08:19 PM
JesseAdams
New Contributor III
I'm trying to copy a field from a joined table to feature class.  This is easily accomplished in ArcMap with the field calculator or in model builder.  However, I can't seem to get it working with Python.  Any help would be greatly appreciated.  Thanks.

arcpy.MakeFeatureLayer_management(sde_SDE_nuts0, sde_nuts0_view)

    # Process: Join Summary Table to NUTS Poly
    arcpy.AddJoin_management(sde_nuts0_view, "NUTS", "sde_SDE_EU_CTY_SUM_view", "Country_Code_NUTS", "KEEP_COMMON")

    # Process: Copy PotPUMTotal - PotPUMTotal field already exists
    arcpy.CalculateField_management(sde_SDE_nuts0, "PotPUMTotal", "[sde.SDE.EU_CTY_SUM_JSA_Test.SUM_PotPUMTotal]", "VB", "")


It errors with Error #999999?
Tags (2)
0 Kudos
4 Replies
NiklasNorrthon
Occasional Contributor III
Field names should be quoted with exclamation marks, not brackets in python. E.g. !my_field!
0 Kudos
JesseAdams
New Contributor III
Good point.  Rookie error.  However, now I receive a "ERROR 000539: Invalid field sde.SDE.EU_CTY_SUM_JSA_Test.SUM_PotPUMTotal" error.  Here is the line I'm using now for copying the field from the joined table:

arcpy.CalculateField_management(sde_SDE_nuts0, "PotPUMTotal", "!sde.SDE.EU_CTY_SUM_JSA_Test.SUM_PotPUMTotal!", "Python", "")


When I don't use the table name in front of the field name I get the same error.  Any suggestions would be great.  Thanks again.
0 Kudos
NiklasNorrthon
Occasional Contributor III
Try the arcpy.ListFields() function to see how it is spelled.
0 Kudos
JesseAdams
New Contributor III
Thanks for the reply.  I copied the name directly from the ListFields() function output.  I'll try again.
0 Kudos