Hello,
I need help to create a script that would allow me to loop through multiple tables in a geodatabase and join them to the correct feature class in another geodatabase. There are in total 77 tables and 77 feature classes. I would tell GIS to join those where a portion of the table name matches a portion of the Feature class name.
For example:
Table Name 1: "NAL11F201901"
Feature class 1: "T11"
Table Name 2: "NAL12F201901
Feature Class 2: "T12"
Important:
- All of the tables and the feature classes have the same unique field name.
- I need to join all of the fields.
- The join needs to be permanent.
I am not sure if Add join is better to use or if I should use Join field.
I don't really know what to do next.
I would really appreciate any help with this.
Thanks!
<SPAN class="keyword token">import</SPAN> arcpy
in_features <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"D:\APRX_MXDS\USA_Parcels_2019_Project\Florida_Parcels_Per_County_Final.gdb"</SPAN>
join_tables <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"D:\APRX_MXDS\USA_Parcels_2019_Project\Florida_Property_Data_Per_County.gdb"</SPAN>
list_infeatures <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListFeatureClasses<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
list_join_tables <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListTables<SPAN class="punctuation token">(</SPAN><SPAN class="operator token">*</SPAN>NAL<SPAN class="punctuation token">)</SPAN>
UniqueField <SPAN class="operator token">=</SPAN> <SPAN class="string token">"CO_PARCELID"</SPAN>
<SPAN class="keyword token">for</SPAN> fc <SPAN class="keyword token">in</SPAN> list_infeatures<SPAN class="punctuation token">:</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddJoin_management<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>