I am trying to remove a join in arcpy and have been all over the forums and help topics but cannot get my script to remove the join.
I have tried many combinations of inputs to the remove join but to no avail.
Name94 = "C:\\a\\b\\c\\input1.shp"
Name95 = "C:\\a\\b\\c\\input2.shp"
TablesView = "C:\\a\\b\\c\\TablesView.lyr"
arcpy.MakeFeatureLayer_management(Name94, TablesView)
arcpy.AddJoin_management(TablesView, "Buf_Units", Name95, "Units", "KEEP_ALL")
arcpy.CalculateField_management(TablesView, "Buf_Area", "[Area]", "VB", "")
arcpy.RemoveJoin_management(TablesView, "Buf_Units")
This yields the error:
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000800: The value is not a member of | Input2.
Failed to execute (RemoveJoin).
In place of buf_units I have tried:
arcpy.RemoveJoin_management(TablesView, "'"+Name95.rstrip(".shp")+"'")
arcpy.RemoveJoin_management(TablesView)
arcpy.RemoveJoin_management(TablesView, "input2")
arcpy.RemoveJoin_management(TablesView, Name95)
arcpy.RemoveJoin_management(TablesView, "units")
The previous error is the result of most of these tries but when it is not it is:
ExecuteError: ERROR 000229: Cannot open C:\a\b\c\TablesView.lyr
Failed to execute (RemoveJoin).
I am running python 2.7, 64bit, 10.1 arcgis
1 Answer 1
I think your code doesn't work because MakeFeatureLayer_management() creates a layer (in memory) , not a layer file (.lyr).
Just replace your TablesView variable, e.g.
TablesView = "TablesView"
and you shouldn't get that error anymore.
-
Of all the combinations I tried, I did not try that. That did it! Thanks. arcpy.RemoveJoin_management("TablesView")D_C– D_C2015年01月29日 16:19:42 +00:00Commented Jan 29, 2015 at 16:19
Explore related questions
See similar questions with these tags.
name94
,name95
andTablesView
set to when you run it? I recommend adding print statements to one of your code snippets to show us along with the precise error message that is thrown by that code snippet.