1

I am trying to populate a table by joining an excel sheet to a featureclass and using field calculator to populate the fields, but I am getting errors for the arcpy.addjoin_management.

import arcpy

arcpy.env.workspace = r'C:\Users\vincent.law\Documents\CW_Peter_Lougheed_PP.gdb'
jointable = r'C:\Users\vincent.law\Documents\BoultenCreek1.xlsx\Sheet1$'

arcpy.AddField_management("Campsite", "Campground_NameCampsite_Number", "TEXT","","","","", "NULLABLE", "REQUIRED")
arcpy.CalculateField_management("Campsite", "Campground_NameCampsite_Number", "!Campground_Name!+ !Campsite_Number!", "PYTHON_9.3", "")
arcpy.AddJoin_management("Campsite", "Campground_NameCampsite_Number", "jointable", "Campground_NameCampsite_Number", "KEEP_ALL")
arcpy.CalculateField_management("Campsite","Campsite.Pad_Length","[Sheet1$.Pad_Length]","VB", "")
arcpy.CalculateField_management("Campsite","Campsite.Pad_Min_Width","[Sheet1$.Pad_Min_Width]","VB", "")
arcpy.CalculateField_management("Campsite","Campsite.Campsite_Type","[Sheet1$.Campsite_Type]","VB", "")
RemoveJoin_management("Campsite")
DeleteField_management("Campsite", "Campground_NameCampsite_Number")

File "C:\Python27\ArcGISx6410.3\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript exec codeObject in main.dict File "\goa\desktop\T_Z\vincent.law\Desktop\campsite.py", line 8, in arcpy.AddJoin_management("Campsite", "Campground_NameCampsite_Number", "jointable", "Campground_NameCampsite_Number", "KEEP_ALL") File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 6120, in AddJoin raise e ExecuteError: Failed to execute. Parameters are not valid. The value cannot be a feature class

ERROR 000840: The value is not a Raster Layer.

ERROR 000840: The value is not a Raster Catalog Layer.

ERROR 000840: The value is not a Mosaic Layer.

WARNING 000970: The join field Campground_NameCampsite_Number in the join table Campsite is not indexed. To improve performance, we recommend that an index be created for the join field in the join table.

ERROR 000732: Join Table: Dataset jointable does not exist or is not supported Failed to execute (AddJoin).

1 Answer 1

2

Joins need to be on layers, not feature classes. There's a hint in the error message - The value cannot be a feature class

arcpy.MakeFeatureLayer_management("campsite", "campsite_layer")
arcpy.AddJoin_management("campsite_layer", ......
4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.