3

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

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jan 27, 2015 at 19:28
9
  • Are you running this inside of ArcMap ? or running it from an IDE? Cannot open errors happened to me when I forgot to specify a working environment. Commented Jan 27, 2015 at 20:23
  • I am running in pythonwin. The code above is just a snipet. I have a working environment set. TablesView is implicitly defined as well (C:\\a\\b\\c\\TablesView.lyr) I had to implicitly create layer files for my make feature layer operations to work in a loop. Commented Jan 27, 2015 at 20:27
  • I think your question will be much easier to answer if you edit it to focus on why just one of your examples is not working. Taking your first example, what are the variable name94, name95 and TablesView 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. Commented Jan 27, 2015 at 21:48
  • From your very first example, simply try: Name95.rstrip(".shp") (without the addition of quotes). Commented Jan 27, 2015 at 21:59
  • @KHibma tried it and got error 000800. Parameters are not valid. The value is not a member of | ISOstep95 Commented Jan 27, 2015 at 22:47

1 Answer 1

2

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.

answered Jan 29, 2015 at 10:57
1
  • Of all the combinations I tried, I did not try that. That did it! Thanks. arcpy.RemoveJoin_management("TablesView") Commented Jan 29, 2015 at 16:19

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.