<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: AddJoin failed in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91582#M7141</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thank you for the help.&lt;BR /&gt;The AddJoin code below worked well.&lt;BR /&gt;As you said, I want to add a loop to the AddJoin of a grid and multiple bird range.&lt;BR /&gt;Please kindly advise how to code it.&lt;BR /&gt;Thank you.&lt;BR /&gt; &lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
################################################## ########################
##AddJoin feature layers to a feature layer
##Elaine Kuo
##30 June 2013
################################################## #######################

#Import standard library modules
import arcgisscripting
import os

#Create the Geoprocessor object
gp = arcgisscripting.create(9.3)
gp.QualifiedFieldNames = "UNQUALIFIED"

#Get a list of the featureclasses in the input folder
source_fc = r"H:/temp_D/testt/A_grid.shp"
Entity = r"H:/temp_D/test/geoc0283.shp"
output_fc = r"H:/temp_D/test/grid_rng.shp"

gp.Toolbox = "Data Management"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# convert a featureclass to a layer 
gp.MakeFeatureLayer_management (source_fc, "source_lyr")

# have Layers for AddJoin
gp.AddJoin_management("source_lyr", "GID", Entity, "GID", "KEEP_ALL")

# convert a layer to a featureclass 
gp.CopyFeatures_management ("source_lyr", output_fc)

# delete Field
gp.deletefield (output_fc, "FID_1; GID_1")

# Remove the join
gp.RemoveJoin("source_lyr", "geoc0283")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# clear memory of layers
gp.Delete("source_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
gp.AddMessage(gp.GetMessages())
print gp.GetMessages()
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Great.&amp;nbsp; So this is the core of any loop you would build if you needed to process multiple bird range shape files against the grid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In another post you mentioned you have one grid shape file and 50 bird range shape files.&amp;nbsp; Do you need one final shape file that has 50 fields for all of those bird ranges or do you want 50 separate shape files that match each one of the bird ranges to the grid separately?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 23:30:20 GMT</pubDate>
    <dc:creator>RichardFairhurst</dc:creator>
    <dc:date>2021-12-10T23:30:20Z</dc:date>
    <item>
      <title>AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91572#M7131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;System: Vista, ArcGIS 9.3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wrote a python code to AddJoin a grid shapefile (File A) to a bird range shapefile (File B).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;They have a field in common (GID).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, the error message is &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000732: Input Features: Dataset H:/temp_D/testt does not exist or is not supported&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (MakeFeatureLayer).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please kindly advise how to modify the code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(The file location is &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"H:/temp_D/testt/grid.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"H:/temp_D/test/birdrange.shp")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;#Import standard library modules import arcgisscripting import os&amp;nbsp; #Create the Geoprocessor object gp = arcgisscripting.create(9.3)&amp;nbsp; #Get a list of the featureclasses in the input folder source_fc = "H:/temp_D/testt" Entity = "H:/temp_D/test" outputfolder = "H:/temp_D"&amp;nbsp; gp.Toolbox = "Data Management" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # convert a featureclass to a layer&amp;nbsp; gp.MakeFeatureLayer_management (source_fc, "source_lyr")&amp;nbsp; # have Layers for AddJoin gp.AddJoin_management("source_lyr", "GID", Entity, "GID", "KEEP_ALL")&amp;nbsp; # convert a layer to a featureclass&amp;nbsp; gp.CopyFeatures_management ("source_lyr", source_fc) gp.FeatureClassToShapefile_conversion(source_fc, outputfolder)&amp;nbsp; # clear memory of layers gp.Delete("source_lyr") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage(gp.GetMessages()) print gp.GetMessages()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Jun 2013 09:44:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91572#M7131</guid>
      <dc:creator>ElaineKuo</dc:creator>
      <dc:date>2013-06-30T09:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91573#M7132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;System: Vista, ArcGIS 9.3&lt;BR /&gt;&lt;BR /&gt;Hello, &lt;BR /&gt;&lt;BR /&gt;I wrote a python code to AddJoin a grid shapefile (File A) to a bird range shapefile (File B).&lt;BR /&gt;They have a field in common (GID).&lt;BR /&gt;&lt;BR /&gt;However, the error message is &lt;BR /&gt;ERROR 000732: Input Features: Dataset H:/temp_D/testt does not exist or is not supported&lt;BR /&gt;Failed to execute (MakeFeatureLayer).&lt;BR /&gt;&lt;BR /&gt;Please kindly advise how to modify the code.&lt;BR /&gt;Thank you.&lt;BR /&gt;(The file location is &lt;BR /&gt;"H:/temp_D/testt/grid.shp"&lt;BR /&gt;"H:/temp_D/test/birdrange.shp")&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
#Import standard library modules
import arcgisscripting
import os

#Create the Geoprocessor object
gp = arcgisscripting.create(9.3)

#Get a list of the featureclasses in the input folder
source_fc = "H:/temp_D/testt"
Entity = "H:/temp_D/test"
outputfolder = "H:/temp_D"

gp.Toolbox = "Data Management"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# convert a featureclass to a layer 
gp.MakeFeatureLayer_management (source_fc, "source_lyr")

# have Layers for AddJoin
gp.AddJoin_management("source_lyr", "GID", Entity, "GID", "KEEP_ALL")

# convert a layer to a featureclass 
gp.CopyFeatures_management ("source_lyr", source_fc)
gp.FeatureClassToShapefile_conversion(source_fc, outputfolder)

# clear memory of layers
gp.Delete("source_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
gp.AddMessage(gp.GetMessages())
print gp.GetMessages()
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The error makes it fairly apparent what the problem is.&amp;nbsp; You did not provide any actual input feature classes in your code, nor did you actually read the directories to get the feature classes (so your comment in the code is wrong).&amp;nbsp; You also must feed in paths as either raw strings or with double slashes "//".&amp;nbsp; Change this part this way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Provide the input shapefiles and output shapefiles&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;source_fc = r"H:/temp_D/testt/grid.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Entity = r"H:/temp_D/test/birdrange.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;output_fc = r"H:/temp_D/test/grid_rng.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you get the same error still it is because these are not the actual paths or file names and you should verify that you have written them out correctly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your code has other errors within it.&amp;nbsp; It will also break where you try to copy a feature class over itself in Copy Features line and you don't need to run the conversion to a shape file if you output the CopyFeatures to a new shapefile in the first place.&amp;nbsp; So use the output_fc line I changed above and change the Copy Features part from:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# convert a layer to a featureclass &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.CopyFeatures_management ("source_lyr", source_fc)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.FeatureClassToShapefile_conversion(source_fc, outputfolder)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;to&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Copy features to a Shape File &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.CopyFeatures_management ("source_lyr", output_fc)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You may not like the result using a shapefile, however, since joins will corrupt the field names when they truncate to 10 characters and just keep the table names.&amp;nbsp; I hate shapefiles for that reason and only use Feature Classes in file geodatabases in my models.&amp;nbsp; But with layer settings and aliases you might be able to prevent that corruption of your data despite using a shapefile.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I question the use of the Delete tool at the end, since I am not sure it actually clears memory of the layer only and won't delete the data.&amp;nbsp; It may be the correct way to do it, but I have not tried it.&amp;nbsp; You should also add a Remove Join tool in the script prior to trying to delete the layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Since everything in this script except the last few lines can be set up in ModelBuilder, I recommend recreating the whole model in ModelBuilder from scratch.&amp;nbsp; Complete each tool input correctly in ModelBuilder, and run the model to verify it actually works.&amp;nbsp; Make sure the output deals with field names the way you want.&amp;nbsp; Then if this tool is supposed to be rerun regularly, set it up to run a second time by adding a Delete tool to delete the output shapefile of the Copy Feature tool, or it will throw an error saying the output files already exists.&amp;nbsp; After the tool runs successfully in ModelBuilder the second time, output it as a Python script and add the last few lines.&amp;nbsp; Then it is ready to run as a batch script on a regular schedule.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:30:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91573#M7132</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-10T23:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91574#M7133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;A few other thought on your model.&amp;nbsp; It only works if the grids match just one bird range.&amp;nbsp; It they match two or more bird ranges, a join won't handle that.&amp;nbsp; In that case you would have to convert your grid and bird range shapefiles into two feature classes within a single File geodatabase, and then use the Make Query Table tool instead to deal with the one to many or many to many relationship.&amp;nbsp; Or else consider using the Spatial Join tool instead with the One to Many option and a small negative tolerance or the One to One option and some merge rules to join up multiple bird range values into summary fields or list fields.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The ModelBuilder to script approach does not create the prettiest, compact code, but I almost always create gp tools in ModelBuilder and export them as python scripts to make sure I get the syntax and paths correct, rather than write them out directly in a python editor.&amp;nbsp; Troubleshooting a model is a lot easier than troubleshooting a python script for me.&amp;nbsp; And frankly it is a good way to learn Python if you are not that experienced in writing python code.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Jun 2013 12:39:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91574#M7133</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2013-06-30T12:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91575#M7134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the clear explanation for a beginner like me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please kindly help again with the questions following your advice.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You also must feed in paths as either raw strings or with double slashes "//".&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;=&amp;gt; Please kindly give an example of double slashes and explain why not using double slashes in the path below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Change this part this way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Provide the input shapefiles and output shapefiles&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;source_fc = r"H:/temp_D/testt/grid.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Entity = r"H:/temp_D/test/birdrange.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;output_fc = r"H:/temp_D/test/grid_rng.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you get the same error still it is because these are not the actual paths or file names.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;=&amp;gt; The message says "ERROR 000732: Join Table: Dataset H:/temp_D/test/birdrange.shp does not exist."&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please kindly advise how to name the result shapefile if not preexist yet.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You should also add a Remove Join tool in the script prior to trying to delete the layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;=&amp;gt; Thank you for reminding.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Complete each tool input correctly in ModelBuilder, and run the model to verify it actually works.&amp;nbsp; Make sure the output deals with field names the way you want.&amp;nbsp; Then if this tool is supposed to be rerun regularly, set it up to run a second time by adding a Delete tool to delete the output shapefile of the Copy Feature tool, or it will throw an error saying the output files already exists.&amp;nbsp; After the tool runs successfully in ModelBuilder the second time, output it as a Python script and add the last few lines.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;=&amp;gt; Please kindly advise how to output a modelbuilder as a Python script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Totally agreed with you on the idea of ModelBuilder.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I used to do the batch addjoin using ModelBuilder (one grid to 100 bird ranges.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; However, this time the working load increased (one grid to 3000 bird ranges)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; That's why I want to try pyton.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Jun 2013 22:43:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91575#M7134</guid>
      <dc:creator>ElaineKuo</dc:creator>
      <dc:date>2013-06-30T22:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91576#M7135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; It they match two or more bird ranges, a join won't handle that.&amp;nbsp; In that case you would have to convert your grid and bird range shapefiles into two feature classes within a single File geodatabase, and then use the Make Query Table tool instead to deal with the one to many or many to many relationship.&amp;nbsp; Or else consider using the Spatial Join tool instead with the One to Many option and a small negative tolerance or the One to One option and some merge rules to join up multiple bird range values into summary fields or list fields.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for the important advice on File geodatabase.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It is new to me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please kindly &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1.introduce any references on File geodatabase&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. how to run "AddJoin" for a grid and multiple bird range shapefiles in File geodatabase.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried Spatial Join tool. It took 13 seconds to complete a join of a grid and a bird range. (it only took one second to use AddJoin.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Jun 2013 22:49:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91576#M7135</guid>
      <dc:creator>ElaineKuo</dc:creator>
      <dc:date>2013-06-30T22:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91577#M7136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here are my responses:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;=&amp;gt; Please kindly give an example of double slashes and explain why not using double slashes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;=&amp;gt; in the path below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The slash is an escape character in python and is not read as a text character unless the entire string is preceded by an r to make it a raw string interpreted without handling escape characters or the slash is repeated to make it a literal text slash.&amp;nbsp; So only these two versions work: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;source_fc = r"H:/temp_D/testt/grid.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;source_fc = "H://temp_D//testt//grid.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;=&amp;gt; The message says "ERROR 000732: Join Table: Dataset H:/temp_D/test/birdrange.shp does &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;=&amp;gt; not exist."&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Probably the path is wrong and actually matches the path of the grid.&amp;nbsp; To verify the path use Windows Explorer and find the file and its path and copy that path into the code.&amp;nbsp; I expect you will find it is actually:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Entity = r"H:/temp_D/testt/birdrange.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;=&amp;gt; Please kindly advise how to output a modelbuilder as a Python script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;From &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//002w00000031000000"&gt;this help&lt;/A&gt;&lt;SPAN&gt; (10.1 but it should be the same with 9.3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steps:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;From the menu in ModelBuilder, point to and click Model &amp;gt; Export &amp;gt; To Python Script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Click the Save in drop-down arrow and navigate to the location where you want to save your script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Type a file name for the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Click Save.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;=&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Totally agreed with you on the idea of ModelBuilder.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;=&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I used to do the batch addjoin using ModelBuilder (one grid to 100 bird ranges.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;=&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; However, this time the working load increased (one grid to 3000 bird ranges)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;=&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; That's why I want to try python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If all you are doing is a normal Join and Copy Feature using gp tools, it is the same thing to use Model Builder as it is to python.&amp;nbsp; Python would only make a difference if you were using python specific code, such as cursors, loops, or python functions.&amp;nbsp; So just build it in Model Builder.&amp;nbsp; Even if it turns out you need a loop, build a single process that works first and then worry about putting it inside a loop.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you are actually doing a join of one grid to 100 bird ranges then it sounds like maybe you are doing something other than what I am reading in your code.&amp;nbsp; Were you using an iterator in Model Builder before to process one grid against 100 bird range joins involving 100 shape files?&amp;nbsp; Right now you code only does one join, which will only join one grid to one bird range.&amp;nbsp; So what do you really intend to do here?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 01:34:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91577#M7136</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2013-07-01T01:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91578#M7137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Right now you code only does one join, which will only join one grid to one bird range. So what do you really intend to do here?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;=&amp;gt; a quick response.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;just as you said, I made a try of a grid to one bird range to see if the code is basically right. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The loop did not start yet.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;By the way, for model builder, I copied the whole process of AddJoin for 10 times and ran it for 10 joins simultaneously.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you always for the in-time and clear explanation.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 02:30:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91578#M7137</guid>
      <dc:creator>ElaineKuo</dc:creator>
      <dc:date>2013-07-01T02:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91579#M7138</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Right now you code only does one join, which will only join one grid to one bird range. So what do you really intend to do here?&lt;BR /&gt;=&amp;gt; a quick response.&lt;BR /&gt;just as you said, I made a try of a grid to one bird range to see if the code is basically right. &lt;BR /&gt;The loop did not start yet.&lt;BR /&gt;&lt;BR /&gt;By the way, for model builder, I copied the whole process of AddJoin for 10 times and ran it for 10 joins simultaneously.&lt;BR /&gt;&lt;BR /&gt;Thank you always for the in-time and clear explanation.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;OK.&amp;nbsp; Then once you get a single join going you will need a loop to read the bird ranges and do the joins before doing the copy features.&amp;nbsp; You may have to do it in chunks, since I am not sure how many simultaneous joins are allowed before you run out of memory or hit some other limit.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Spatial Join idea was for the case where all of your bird ranges were appended together in one feature class.&amp;nbsp; Then it makes sense to do that.&amp;nbsp; With each bird range in a separate file Add Join makes sense and the Spatial join doesn't help.&amp;nbsp; Also, that make more sense why you want to try python, since a loop through the bird range directory can do the joins faster than setting up each in a string in Model Builder.&amp;nbsp; Model Builder could maybe do it with an iterator, but iterators don't export to python.&amp;nbsp; So once your code works for a single instance then come back and show it to get help building a python file reading loop.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 05:17:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91579#M7138</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2013-07-01T05:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91580#M7139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for the help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The AddJoin code below worked well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As you said, I want to add a loop to the AddJoin of a grid and multiple bird range.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please kindly advise how to code it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
################################################## ########################
##AddJoin feature layers to a feature layer
##Elaine Kuo
##30 June 2013
################################################## #######################

#Import standard library modules
import arcgisscripting
import os

#Create the Geoprocessor object
gp = arcgisscripting.create(9.3)
gp.QualifiedFieldNames = "UNQUALIFIED"

#Get a list of the featureclasses in the input folder
source_fc = r"H:/temp_D/testt/A_grid.shp"
Entity = r"H:/temp_D/test/geoc0283.shp"
output_fc = r"H:/temp_D/test/grid_rng.shp"

gp.Toolbox = "Data Management"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# convert a featureclass to a layer 
gp.MakeFeatureLayer_management (source_fc, "source_lyr")

# have Layers for AddJoin
gp.AddJoin_management("source_lyr", "GID", Entity, "GID", "KEEP_ALL")

# convert a layer to a featureclass 
gp.CopyFeatures_management ("source_lyr", output_fc)

# delete Field
gp.deletefield (output_fc, "FID_1; GID_1")

# Remove the join
gp.RemoveJoin("source_lyr", "geoc0283")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# clear memory of layers
gp.Delete("source_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
gp.AddMessage(gp.GetMessages())
print gp.GetMessages()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:30:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91580#M7139</guid>
      <dc:creator>ElaineKuo</dc:creator>
      <dc:date>2021-12-10T23:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91581#M7140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Just for the record, a single forward slash ("/") works fine, it's the backslash ("\") that's illegal.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The following techniques will all work in a path:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="color:#333333;"&gt;1.) forward &lt;/SPAN&gt;&lt;SPAN style="color:#333333;"&gt;slashes&lt;/SPAN&gt;&lt;SPAN style="color:#333333;"&gt; = /&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color:#333333;"&gt;2.) double backslashes = \\&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color:#333333;"&gt;3.) raw string with backslashes = r&lt;/SPAN&gt;&lt;SPAN style="color: #3E3E3E; font-family: Arial;"&gt;"H:\InfoRequest"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 11:29:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91581#M7140</guid>
      <dc:creator>RDHarles</dc:creator>
      <dc:date>2013-07-01T11:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91582#M7141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thank you for the help.&lt;BR /&gt;The AddJoin code below worked well.&lt;BR /&gt;As you said, I want to add a loop to the AddJoin of a grid and multiple bird range.&lt;BR /&gt;Please kindly advise how to code it.&lt;BR /&gt;Thank you.&lt;BR /&gt; &lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
################################################## ########################
##AddJoin feature layers to a feature layer
##Elaine Kuo
##30 June 2013
################################################## #######################

#Import standard library modules
import arcgisscripting
import os

#Create the Geoprocessor object
gp = arcgisscripting.create(9.3)
gp.QualifiedFieldNames = "UNQUALIFIED"

#Get a list of the featureclasses in the input folder
source_fc = r"H:/temp_D/testt/A_grid.shp"
Entity = r"H:/temp_D/test/geoc0283.shp"
output_fc = r"H:/temp_D/test/grid_rng.shp"

gp.Toolbox = "Data Management"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# convert a featureclass to a layer 
gp.MakeFeatureLayer_management (source_fc, "source_lyr")

# have Layers for AddJoin
gp.AddJoin_management("source_lyr", "GID", Entity, "GID", "KEEP_ALL")

# convert a layer to a featureclass 
gp.CopyFeatures_management ("source_lyr", output_fc)

# delete Field
gp.deletefield (output_fc, "FID_1; GID_1")

# Remove the join
gp.RemoveJoin("source_lyr", "geoc0283")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# clear memory of layers
gp.Delete("source_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
gp.AddMessage(gp.GetMessages())
print gp.GetMessages()
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Great.&amp;nbsp; So this is the core of any loop you would build if you needed to process multiple bird range shape files against the grid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In another post you mentioned you have one grid shape file and 50 bird range shape files.&amp;nbsp; Do you need one final shape file that has 50 fields for all of those bird ranges or do you want 50 separate shape files that match each one of the bird ranges to the grid separately?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:30:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91582#M7141</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-10T23:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91583#M7142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Just for the record, a single forward slash ("/") works fine, it's the backslash ("\") that's illegal.&lt;BR /&gt;&lt;BR /&gt;The following techniques will all work in a path:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="color:#333333;"&gt;1.) forward &lt;/SPAN&gt;&lt;SPAN style="color:#333333;"&gt;slashes&lt;/SPAN&gt;&lt;SPAN style="color:#333333;"&gt; = /&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color:#333333;"&gt;2.) double backslashes = \\&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color:#333333;"&gt;3.) raw string with backslashes = r&lt;/SPAN&gt;&lt;SPAN style="color: #3E3E3E; font-family: Arial;"&gt;"H:\InfoRequest"&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the clarification.&amp;nbsp; Python is not my language of choice, and the escape character and path string handling is something that trips me up and many other posts in this forum.&amp;nbsp; So I figured it could be related to his problem (even though my answer made the problem worse on that issue).&amp;nbsp; One of the reasons I use Model Builder instead of typing in Python directly when I get errors about paths.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 11:36:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91583#M7142</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2013-07-01T11:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91584#M7143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks for the clarification.&amp;nbsp; Python is not my language of choice, and the escape character and path string handling is something that trips me up and many other posts in this forum.&amp;nbsp; So I figured it could be related to his problem (even though my answer made the problem worse on that issue).&amp;nbsp; One of the reasons I use Model Builder instead of typing in Python directly when I get errors about paths.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I agree with you, getting the path (and slashes) correct seems to be a common problem out there.&amp;nbsp; In fact a great number of people I come across incorrectly think that this is a back slash ("/") and this is a forward slash ("\"), which in fact is the opposite.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 11:48:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91584#M7143</guid>
      <dc:creator>RDHarles</dc:creator>
      <dc:date>2013-07-01T11:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91585#M7144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Great.&amp;nbsp; &lt;BR /&gt;So this is the core of any loop you would build if you needed to process multiple bird range shape files against the grid.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the encouragement.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I want "one final shape file that has 50 fields for all of those bird ranges."&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Actually, I tried the below code for a grid to a bird range only.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It failed in RemoveJoin, saying "ERROR 000800: The value is not a member of geoc0283.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (RemoveJoin)." (geoc0283 is the name of one bird range).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
################################################## ########################
##AddJoin feature layers to a feature layer
##Elaine Kuo
##01 July 2013
################################################## #######################

#Import standard library modules
import arcgisscripting
import os

#Create the Geoprocessor object
gp = arcgisscripting.create(9.3)
gp.QualifiedFieldNames = "UNQUALIFIED"

#Set the input workspace
workingfolder= r"H:/temp_D/test"
gp.Workspace = workingfolder

#Set the output workspace
outputfolder= r"H:/temp_D"
outWorkspace= outputfolder

source_fc = r"H:/temp_D/testt/A_grid.shp"
Entity = r"H:/temp_D/test/geoc0283.shp"

#Get a list of the featureclasses in the input folder
fcs = gp.ListFeatureClasses()

# Loop through every item in the list that was just generated
for fc in fcs:

&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.Toolbox = "Data Management"

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Make a FeatureClass layer&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.MakeFeatureLayer_management (source_fc, "source_lyr")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # have Layers for AddJoin
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddJoin_management("source_lyr", "GID", fc, "GID", "KEEP_ALL")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # convert a layer to a featureclass 
&amp;nbsp;&amp;nbsp;&amp;nbsp; out_name = gp.Describe("source_lyr").name
&amp;nbsp;&amp;nbsp;&amp;nbsp; out_name = gp.ValidateTableName(out_name, outputfolder)
&amp;nbsp;&amp;nbsp;&amp;nbsp; out_shape = outputfolder + "/" + out_name + ".shp"
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.CopyFeatures_management ("source_lyr", out_shape)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # delete Field
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.deletefield (out_shape, "FID_1; GID_1")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove the join
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.RemoveJoin("source_lyr", fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # clear memory of layers
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.Delete("source_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
gp.AddMessage(gp.GetMessages())
print gp.GetMessages()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:30:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91585#M7144</guid>
      <dc:creator>ElaineKuo</dc:creator>
      <dc:date>2021-12-10T23:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91586#M7145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;While the core of your loop was contained in the code you wrote, only the join belongs within loop.&amp;nbsp; Now that I know what you really want at the end try this (not sure it will work, since I never tried 50 joins in a loop before).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
################################################## ########################
##AddJoin feature layers to a feature layer
##Elaine Kuo
##01 July 2013
################################################## #######################

#Import standard library modules
import arcgisscripting
import os

#Create the Geoprocessor object
gp = arcgisscripting.create(9.3)
gp.QualifiedFieldNames = "UNQUALIFIED"

#Set the input workspace
workingfolder= "H:/temp_D/test"
gp.Workspace = workingfolder

#Set the output workspace
outputfolder= "H:/temp_D"
outWorkspace= outputfolder

source_fc = "H:/temp_D/testt/A_grid.shp"
Entity = "H:/temp_D/test/geoc0283.shp"

#Get a list of the featureclasses in the input folder
fcs = gp.ListFeatureClasses()

gp.Toolbox = "Data Management"

# Make a FeatureClass layer&amp;nbsp;&amp;nbsp;&amp;nbsp; 
gp.MakeFeatureLayer_management (source_fc, "source_lyr")

# Loop through every item in the list that was just generated
for fc in fcs:

&amp;nbsp;&amp;nbsp;&amp;nbsp; # have Layers for AddJoin
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddJoin_management("source_lyr", "GID", fc, "GID", "KEEP_ALL")

# convert a layer to a featureclass 
out_name = gp.Describe("source_lyr").name
out_name = gp.ValidateTableName(out_name, outputfolder)
out_shape = outputfolder + "/" + out_name + ".shp"

gp.CopyFeatures_management ("source_lyr", out_shape)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# delete Field&amp;nbsp; (need to clean up with a lot more ID fields that the code you have below since now there are 50 GID values.)
gp.deletefield (out_shape, "FID_1; GID_1")

# Don't bother removing 50 joins, just kill the layer
# clear memory of layers
gp.Delete("source_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
gp.AddMessage(gp.GetMessages())
print gp.GetMessages()
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error you reported is due to the fact that you were not doing a single fc, but a loop of all the fcs.&amp;nbsp; I also would just assign a name for the final output rather than deriving it from the layer, since that step only runs once now to create a single shape file at the end.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If this code does not throw an error and creates an output, do not be surprised if the output only contains one join or no join.&amp;nbsp; That is the part I am not sure about when you do multiple joins on top of each other and a possibility related to the error you reported in your last post.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:30:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91586#M7145</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-10T23:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91587#M7146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I agree with you, getting the path (and slashes) correct seems to be a common problem out there.&amp;nbsp; In fact a great number of people I come across incorrectly think that this is a back slash ("/") and this is a forward slash ("\"), which in fact is the opposite.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;There is actually a fourth case that works (although it is unnecessary since the other 3 path syntax formats you gave work more elegantly)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;4.) raw string with slashes = r"H:/InfoRequest"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In essence it is the same as just using slashes, but nonetheless it will work and not throw an error if it is used.&amp;nbsp; So it technically is a 4th working case, even if it is not recommended.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 13:15:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91587#M7146</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2013-07-01T13:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91588#M7147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I just tried creating a Model Builder model where I did three successive joins.&amp;nbsp; For the second and third join I had to use the qualified field name of the original layer feature class.&amp;nbsp; So the loop probably needs to be modified to keep track of the first time a join is done and all other times the join is done.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
################################################## ########################
##AddJoin feature layers to a feature layer
##Elaine Kuo
##01 July 2013
################################################## #######################

#Import standard library modules
import arcgisscripting
import os

#Create the Geoprocessor object
gp = arcgisscripting.create(9.3)
gp.QualifiedFieldNames = "UNQUALIFIED"

#Set the input workspace
workingfolder= "H:/temp_D/test"
gp.Workspace = workingfolder

#Set the output workspace
outputfolder= "H:/temp_D"
outWorkspace= outputfolder

source_fc = "H:/temp_D/testt/A_grid.shp"
Entity = "H:/temp_D/test/geoc0283.shp"

#Get a list of the featureclasses in the input folder
fcs = gp.ListFeatureClasses()

gp.Toolbox = "Data Management"

# Make a FeatureClass layer&amp;nbsp;&amp;nbsp;&amp;nbsp; 
gp.MakeFeatureLayer_management (source_fc, "source_lyr")

$ A counter to separate the first time through the loop from all other times
counter = 0
# Loop through every item in the list that was just generated
for fc in fcs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if counter == 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # set up first Layer for AddJoin
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddJoin_management("source_lyr", "GID", fc, "GID", "KEEP_ALL")
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # set up second and following Layers for AddJoin
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddJoin_management("source_lyr", "A_grid.GID", fc, "GID", "KEEP_ALL")
&amp;nbsp;&amp;nbsp;&amp;nbsp; counter += 1

# convert a layer to a featureclass 
out_name = gp.Describe("source_lyr").name
out_name = gp.ValidateTableName(out_name, outputfolder)
out_shape = outputfolder + "/" + out_name + ".shp"

gp.CopyFeatures_management ("source_lyr", out_shape)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# delete Field&amp;nbsp; (need to clean up with a lot more ID fields that the code you have below since now there are 50 GID values.)
gp.deletefield (out_shape, "FID_1; GID_1")

# Don't bother removing 50 joins, just kill the layer
# clear memory of layers
gp.Delete("source_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
gp.AddMessage(gp.GetMessages())
print gp.GetMessages()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:30:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91588#M7147</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-10T23:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91589#M7148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
################################################## ########################
##AddJoin feature layers to a feature layer
##Elaine Kuo
##01 July 2013
################################################## #######################

#Import standard library modules
import arcgisscripting
import os

#Create the Geoprocessor object
gp = arcgisscripting.create(9.3)
gp.QualifiedFieldNames = "UNQUALIFIED"

#Set the input workspace
workingfolder= "H:/temp_D/test"
gp.Workspace = workingfolder

#Set the output workspace
outputfolder= "H:/temp_D"
outWorkspace= outputfolder

source_fc = "H:/temp_D/testt/A_grid.shp"
Entity = "H:/temp_D/test/geoc0283.shp"

#Get a list of the featureclasses in the input folder
fcs = gp.ListFeatureClasses()

gp.Toolbox = "Data Management"

# Make a FeatureClass layer&amp;nbsp;&amp;nbsp;&amp;nbsp; 
gp.MakeFeatureLayer_management (source_fc, "source_lyr")

# Loop through every item in the list that was just generated
for fc in fcs:

&amp;nbsp;&amp;nbsp;&amp;nbsp; # have Layers for AddJoin
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddJoin_management("source_lyr", "GID", fc, "GID", "KEEP_ALL")

# convert a layer to a featureclass 
out_name = gp.Describe("source_lyr").name
out_name = gp.ValidateTableName(out_name, outputfolder)
out_shape = outputfolder + "/" + out_name + ".shp"

gp.CopyFeatures_management ("source_lyr", out_shape)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# delete Field&amp;nbsp; (need to clean up with a lot more ID fields that the code you have below since now there are 50 GID values.)
gp.deletefield (out_shape, "FID_1; GID_1")

# Don't bother removing 50 joins, just kill the layer
# clear memory of layers
gp.Delete("source_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
gp.AddMessage(gp.GetMessages())
print gp.GetMessages()
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks. Here are the test report:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. For grid and 1 bird range shape file =&amp;gt; the code worked well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. For grid and 2 bird range shape files=&amp;gt; the error message: gp.AddJoin_management("source_lyr", "GID", fc, "GID", "KEEP_ALL")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ExecuteError: ERROR 999999: Error executing function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;A locator with this name does not exist.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (AddJoin).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please kindly help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:30:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91589#M7148</guid>
      <dc:creator>ElaineKuo</dc:creator>
      <dc:date>2021-12-10T23:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91590#M7149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
################################################## ########################
##AddJoin feature layers to a feature layer
##Elaine Kuo
##01 July 2013
################################################## #######################

#Import standard library modules
import arcgisscripting
import os

#Create the Geoprocessor object
gp = arcgisscripting.create(9.3)
gp.QualifiedFieldNames = "UNQUALIFIED"

#Set the input workspace
workingfolder= "H:/temp_D/test"
gp.Workspace = workingfolder

#Set the output workspace
outputfolder= "H:/temp_D"
outWorkspace= outputfolder

source_fc = "H:/temp_D/testt/A_grid.shp"
Entity = "H:/temp_D/test/geoc0283.shp"

#Get a list of the featureclasses in the input folder
fcs = gp.ListFeatureClasses()

gp.Toolbox = "Data Management"

# Make a FeatureClass layer&amp;nbsp;&amp;nbsp;&amp;nbsp; 
gp.MakeFeatureLayer_management (source_fc, "source_lyr")

$ A counter to separate the first time through the loop from all other times
counter = 0
# Loop through every item in the list that was just generated
for fc in fcs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if counter == 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # set up first Layer for AddJoin
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddJoin_management("source_lyr", "GID", fc, "GID", "KEEP_ALL")
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # set up second and following Layers for AddJoin
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddJoin_management("source_lyr", "A_grid.GID", fc, "GID", "KEEP_ALL")
&amp;nbsp;&amp;nbsp;&amp;nbsp; counter += 1

# convert a layer to a featureclass 
out_name = gp.Describe("source_lyr").name
out_name = gp.ValidateTableName(out_name, outputfolder)
out_shape = outputfolder + "/" + out_name + ".shp"

gp.CopyFeatures_management ("source_lyr", out_shape)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# delete Field&amp;nbsp; (need to clean up with a lot more ID fields that the code you have below since now there are 50 GID values.)
gp.deletefield (out_shape, "FID_1; GID_1")

# Don't bother removing 50 joins, just kill the layer
# clear memory of layers
gp.Delete("source_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
gp.AddMessage(gp.GetMessages())
print gp.GetMessages()
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The code worked wonderfully for three shapefiles.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As for delete fields, I am thinking if wildcard will help in this condition.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(The field names of the three AddJoin bird range are&amp;nbsp; "FID_1; GID_1", "FID_12; GID_12", and "FID_12_13; GID_12_13")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Therefore, I replaced the gp.delete with the following code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# delete Field&amp;nbsp; (need to clean up with a lot more ID fields that the code you have below since now there are 50 GID values.)
gp.deletefield (out_shape, "FID_*; GID_*")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code worked well, but none of the three FID and GID fields were deleted.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please kindly help and thank you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(It is the first time my problem can be solved so quickly. Thanks greatly.)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:30:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91590#M7149</guid>
      <dc:creator>ElaineKuo</dc:creator>
      <dc:date>2021-12-10T23:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: AddJoin failed</title>
      <link>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91591#M7150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks a lot.&lt;BR /&gt;The code worked wonderfully for three shapefiles.&lt;BR /&gt;As for delete fields, I am thinking if wildcard will help in this condition.&lt;BR /&gt;(The field names of the three AddJoin bird range are&amp;nbsp; "FID_1; GID_1", "FID_12; GID_12", and "FID_12_13; GID_12_13")&lt;BR /&gt;&lt;BR /&gt;Therefore, I replaced the gp.delete with the following code.&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# delete Field&amp;nbsp; (need to clean up with a lot more ID fields that the code you have below since now there are 50 GID values.)
gp.deletefield (out_shape, "FID_*; GID_*")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;The code worked well, but none of the three FID and GID fields were deleted.&lt;BR /&gt;Please kindly help and thank you.&lt;BR /&gt;(It is the first time my problem can be solved so quickly. Thanks greatly.)&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Try this instead:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fieldList = gp.ListFields(out_shape)
for field in fieldList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if field.name[1:3] == "ID_":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.deletefield (out_shape, field.name)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:30:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addjoin-failed/m-p/91591#M7150</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-10T23:30:36Z</dc:date>
    </item>
  </channel>
</rss>

