<?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: Join multiple tables to multiple feature classes arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes/m-p/1031872#M60179</link>
    <description>&lt;P&gt;Ok I think I got it:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

#Define Geodatabase Path
featureGDB = r"C:\C_M2\arcpy\list\list_Events_SBA_wp.gdb"
tableGDB = r"C:\C_M2\arcpy\list\list_distance.gdb"

#Create Feature List Variable
arcpy.env.workspace = featureGDB
featureList = arcpy.ListFeatureClasses()

#Create Table List Variable
arcpy.env.workspace = tableGDB
tableList = arcpy.ListTables()

#Set table Names to featureList Names equivalent
for table in tableList:
    tableNum = table [0:-5]
#Finde Table and Feature from Lists with same Name and join them   
    for feature in featureList:
        if feature == tableNum:
            in_data = featureGDB + "\\" + feature
            in_field = "OBJECTID"
            join_table = tableGDB + "\\" + table
            join_field = "OBJECTID"
            fields = ["DISTANCE"]
            arcpy.JoinField_management(in_data, in_field, join_table, join_field, fields)&lt;/LI-CODE&gt;&lt;P&gt;Thank you!!&lt;/P&gt;</description>
    <pubDate>Tue, 02 Mar 2021 13:04:38 GMT</pubDate>
    <dc:creator>Jörn</dc:creator>
    <dc:date>2021-03-02T13:04:38Z</dc:date>
    <item>
      <title>Join multiple tables to multiple feature classes arcpy</title>
      <link>https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes/m-p/1031556#M60167</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I have a list of tables and a list of feature classes and I would like to join them, based on their names. The tables and feature classes I would like to join have the same name, but the tables hold and additional annex. I think my problem is similar to the one I found here already (&lt;A href="https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes-arcpy/td-p/181549/page/2" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes-arcpy/td-p/181549/page/2&lt;/A&gt;). I tried to copy the script and adapt it to my needs. The script is running without errors but I dont get the results. I would be very gratefull for suggestions. I would also appreciate a solution in model builder where I also could not find the way. Thank you!!&lt;/P&gt;&lt;P&gt;I use ArcMap 10.7 and run the script in the ArcMap python console.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

#Define Geodatabase Path
featureGDB = r"C:\C_M2\arcpy\list\list_Events_SBA_wp.gdb"
tableGDB = r"C:\C_M2\arcpy\list\list_distance.gdb"

#Create Feature List Variable
arcpy.env.workspace = featureGDB
featureList = arcpy.ListFeatureClasses()

#Create Table List Variable
arcpy.env.workspace = tableGDB
tableList = arcpy.ListTables()

#Set table Names to featureList Names equivalent
for table in tableList:
    tableNum = table [0:-5]
#Finde Table and Feature from Lists with same Name and join them   
    for feature in featureList:
        if feature == "%tableNum%":
            arcpy.JoinField_management(in_data="C:\\C_M2\\arcpy\\list\\list_Events_SBA_wp.gdb\\%WP_20200723_001%", in_field="OBJECTID", join_table="C:\\C_M2\\arcpy\\list\\list_distance.gdb\\%WP_20200723_001_dist%", join_field="OBJECTID", fields="DISTANCE")

&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 16:57:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes/m-p/1031556#M60167</guid>
      <dc:creator>Jörn</dc:creator>
      <dc:date>2021-03-01T16:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: Join multiple tables to multiple feature classes arcpy</title>
      <link>https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes/m-p/1031562#M60168</link>
      <description>&lt;P&gt;I've not really studied the code, but the wildcard operator % will not work (to my knowledge).&lt;/P&gt;&lt;P&gt;You would need a regular expression or something like:&lt;/P&gt;&lt;P&gt;if tableNum in feature:&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 17:08:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes/m-p/1031562#M60168</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-03-01T17:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: Join multiple tables to multiple feature classes arcpy</title>
      <link>https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes/m-p/1031567#M60169</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/167692"&gt;@DavidPike&lt;/a&gt;&amp;nbsp;for the suggestion. But do you think that the "%" operator works in the path name of the parameters for joinfield_management? The idea was to use the "%" operator in substition to the f' string, which was used in the posted solution in the link. I think f' strings only work in Python 3 and my version is 2.7.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 17:24:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes/m-p/1031567#M60169</guid>
      <dc:creator>Jörn</dc:creator>
      <dc:date>2021-03-01T17:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: Join multiple tables to multiple feature classes arcpy</title>
      <link>https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes/m-p/1031614#M60170</link>
      <description>&lt;P&gt;why not&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if feature == tableNum:&lt;/LI-CODE&gt;&lt;P&gt;?&lt;/P&gt;&lt;P&gt;And what are the % signs doing in your path names for the join?&amp;nbsp; I think you're mixed up with model builder inline variable substitution - basically get rid of all the % signs, I have no idea what they're doing.&amp;nbsp; the f string in Joe's post was to place a 'T' before the variable, from what I see, you don't need to do anything like that.&lt;/P&gt;&lt;P&gt;You also have a mix of raw and non raw encoded paths, I prefer r'' paths as they look cleaner.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

#Define Geodatabase Path
featureGDB = r"C:\C_M2\arcpy\list\list_Events_SBA_wp.gdb"
tableGDB = r"C:\C_M2\arcpy\list\list_distance.gdb"

#Create Feature List Variable
arcpy.env.workspace = featureGDB
featureList = arcpy.ListFeatureClasses()

#Create Table List Variable
arcpy.env.workspace = tableGDB
tableList = arcpy.ListTables()

#Set table Names to featureList Names equivalent
for table in tableList:
    tableNum = table [0:-5]
#Finde Table and Feature from Lists with same Name and join them   
    for feature in featureList:
        if feature == tableNum:
            in_data = r"C:\C_M2\arcpy\list\list_Events_SBA_wp.gdb\WP_20200723_001"
            in_field = "OBJECTID"
            join_table = r"C:\C_M2\arcpy\list\list_distance.gdb\WP_20200723_001_dist"
            join_field = "OBJECTID"
            fields = ["DISTANCE"]
            arcpy.JoinField_management(in_data, in_field, join_table, join_field, fields)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 01 Mar 2021 19:10:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes/m-p/1031614#M60170</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-03-01T19:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Join multiple tables to multiple feature classes arcpy</title>
      <link>https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes/m-p/1031637#M60171</link>
      <description>&lt;P&gt;F strings are new to python 3.x but the &lt;A href="https://www.w3schools.com/python/ref_string_format.asp" target="_self"&gt;format() method&lt;/A&gt; is it's predecessor in 2.x python.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 19:55:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes/m-p/1031637#M60171</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-03-01T19:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: Join multiple tables to multiple feature classes arcpy</title>
      <link>https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes/m-p/1031825#M60177</link>
      <description>&lt;P&gt;Thanks a lot&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/167692"&gt;@DavidPike&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3374"&gt;@JoeBorgione&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;I&amp;nbsp; indeed am confusing with model builder ...&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, as far as I can interpret the results, the table "WP_20200723_001_dist" joins the "WP_20200723_001" feature the number of times I have features in my featureList (98).&lt;/P&gt;&lt;P&gt;What I want is, that&amp;nbsp;"WP_20200723_001_dist" and&amp;nbsp;"WP_20200723_001" only join one time and that in the second "round" "WP_20200723_002_dist" joins "WP_20200723_002" and so forth till "WP_20200723_098_dist" finally joins "WP_20200723_098".&lt;/P&gt;&lt;P&gt;I thought that the for in statement is useful for this as it iterates through the lists one by one, if I got it right. But I am still unaware of how I should describe the data path dynamically in a form to receive the desired results&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":face_with_rolling_eyes:"&gt;🙄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 09:12:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes/m-p/1031825#M60177</guid>
      <dc:creator>Jörn</dc:creator>
      <dc:date>2021-03-02T09:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: Join multiple tables to multiple feature classes arcpy</title>
      <link>https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes/m-p/1031872#M60179</link>
      <description>&lt;P&gt;Ok I think I got it:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

#Define Geodatabase Path
featureGDB = r"C:\C_M2\arcpy\list\list_Events_SBA_wp.gdb"
tableGDB = r"C:\C_M2\arcpy\list\list_distance.gdb"

#Create Feature List Variable
arcpy.env.workspace = featureGDB
featureList = arcpy.ListFeatureClasses()

#Create Table List Variable
arcpy.env.workspace = tableGDB
tableList = arcpy.ListTables()

#Set table Names to featureList Names equivalent
for table in tableList:
    tableNum = table [0:-5]
#Finde Table and Feature from Lists with same Name and join them   
    for feature in featureList:
        if feature == tableNum:
            in_data = featureGDB + "\\" + feature
            in_field = "OBJECTID"
            join_table = tableGDB + "\\" + table
            join_field = "OBJECTID"
            fields = ["DISTANCE"]
            arcpy.JoinField_management(in_data, in_field, join_table, join_field, fields)&lt;/LI-CODE&gt;&lt;P&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 13:04:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes/m-p/1031872#M60179</guid>
      <dc:creator>Jörn</dc:creator>
      <dc:date>2021-03-02T13:04:38Z</dc:date>
    </item>
  </channel>
</rss>

