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
  • I have added the two line, but now I am getting ERROR 000732: Join Table: Dataset C:\Users\vincent.law\Documents\BoultenCreek1.xlsx\Sheet1$ does not exist or is not supported Failed to execute (AddJoin). Commented Jul 25, 2017 at 16:08
  • If it's processing in the background, xlsx is not supported: resources.arcgis.com/en/help/main/10.1/#/… Commented Jul 25, 2017 at 16:19
  • Also check your xlsx file against these requirements: support.esri.com/en/technical-article/000008903 Commented Jul 25, 2017 at 16:19
  • At least for ERROR 000732 you need to convert the excel spread sheet to an Arc readable format. You can view excel tables in catalog but you cannot interact with them. I would say export to DBF or a comma delimited TXT file and then import that into arcmap. Here is a tool to convert excel to database table. pro.arcgis.com/en/pro-app/tool-reference/conversion/… Commented Jul 25, 2017 at 18:23

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.