<?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: Python: Join Table to Shapefile and export it in Python Snippets Questions</title>
    <link>https://community.esri.com/t5/python-snippets-questions/python-join-table-to-shapefile-and-export-it/m-p/797490#M226</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure how you're determining how to join the other shapefile, but if it's based on name you could do something like below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"C:\data\vector\USA"&lt;/SPAN&gt;

shapefileList &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Get list of shapefiles&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; shapefile &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListFeatureClasses&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"*"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    shapefileList&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;append&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;shapefile&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"C:\data\vector\USA2"&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; shapefile &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListFeatureClasses&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"*"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; shapefile2 &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; shapefileList&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; shapefile &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; shapefile2&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            &lt;SPAN class="comment token"&gt;# Join shapefile fields if names are the same&lt;/SPAN&gt;
            arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;JoinField_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;shapefile&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"JOINFIELD"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; shapefile2&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"JOINFIELD"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"ID, PIN, ADDRESS"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also use the &lt;A href="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/join-field.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Join Field&lt;/A&gt; tool rather than doing a join and then export.&amp;nbsp; This will save you a step.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 09:13:19 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2021-12-12T09:13:19Z</dc:date>
    <item>
      <title>Python: Join Table to Shapefile and export it</title>
      <link>https://community.esri.com/t5/python-snippets-questions/python-join-table-to-shapefile-and-export-it/m-p/797489#M225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can anyone help me to iterate through folders which contain number of shapefiles in it and join them to other shapefiles in different folders and later export as a separate file after joining. I tried it doing using model builder, somehow it worked, but is kind of manual and is really time consuming.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would be of a great help, if there is a python script for it to automate it.&lt;/P&gt;&lt;P&gt;Thank You.&lt;A href="https://community.esri.com/migrated-users/8586"&gt;Jake Skinner&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Feb 2019 00:25:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/python-join-table-to-shapefile-and-export-it/m-p/797489#M225</guid>
      <dc:creator>NirabShrestha</dc:creator>
      <dc:date>2019-02-12T00:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Python: Join Table to Shapefile and export it</title>
      <link>https://community.esri.com/t5/python-snippets-questions/python-join-table-to-shapefile-and-export-it/m-p/797490#M226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure how you're determining how to join the other shapefile, but if it's based on name you could do something like below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"C:\data\vector\USA"&lt;/SPAN&gt;

shapefileList &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Get list of shapefiles&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; shapefile &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListFeatureClasses&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"*"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    shapefileList&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;append&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;shapefile&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"C:\data\vector\USA2"&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; shapefile &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListFeatureClasses&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"*"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; shapefile2 &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; shapefileList&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; shapefile &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; shapefile2&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            &lt;SPAN class="comment token"&gt;# Join shapefile fields if names are the same&lt;/SPAN&gt;
            arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;JoinField_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;shapefile&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"JOINFIELD"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; shapefile2&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"JOINFIELD"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"ID, PIN, ADDRESS"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also use the &lt;A href="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/join-field.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Join Field&lt;/A&gt; tool rather than doing a join and then export.&amp;nbsp; This will save you a step.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:13:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/python-join-table-to-shapefile-and-export-it/m-p/797490#M226</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-12T09:13:19Z</dc:date>
    </item>
  </channel>
</rss>

