How can I include featureClass names with join field names using ModelBuilder ?

1095
3
Jump to solution
12-19-2021 02:55 PM
khalidechlouchi
New Contributor II

Hello!

I try to make a join of the fields using the iterator for multiple FeaturesClasses that have the same fields. So, I should differentiate them by their FeaturesClasses names. like this :  NameFeaturesClasses_NamefildJoin , for example  BATI_CAout_QCooling.

How can I include featureClasses names with join field names using ModelBuilder ?

thank you for your collaboration.

khalidechlouchi_0-1639953774136.png

 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

related how to add the name of FeatureClasses to the names... - Esri Community

Add Join and Join field are your two conventional options.

A third alternative is to build arrays with the desired data using TableToNumPyArray.

Assemble the arrays in NumPy and use ExtendTable once with the resultant or use it multiple times to permanently join to a featureclass table.

You can change the field names in numpy

a = TableToNumPyArray(in_fc, "*", skip_nulls=True)
flds = a.dtype.names
new_flds = [f"Bati_{i}" for i in flds]
new_flds
 
['Bati_OBJECTID',
 'Bati_Shape',
 'Bati_ids',
 'Bati_CENTROID_X',
 'Bati_CENTROID_Y',
 'Bati_INSIDE_X',
 'Bati_INSIDE_Y',
 'Bati_PART_COUNT',
 'Bati_PNT_COUNT',
 'Bati_Sort_',
 'Bati_Shape_Length',
 'Bati_Shape_Area']
# ---
# -- magic time
from arcpy.da import ExtendTable
a.dtype.names = new_flds
sub_arr = a[['Bati_OBJECTID', 'Bati_PART_COUNT']]
ExtendTable(in_fc, "OBJECTID", sub_arr, 'Bati_OBJECTID')

Magic done

extend_table.png

of course you would want a preselected list of fields to produce/slice fields from the main array to make sub_arr.

 

 


... sort of retired...

View solution in original post

0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

related how to add the name of FeatureClasses to the names... - Esri Community

Add Join and Join field are your two conventional options.

A third alternative is to build arrays with the desired data using TableToNumPyArray.

Assemble the arrays in NumPy and use ExtendTable once with the resultant or use it multiple times to permanently join to a featureclass table.

You can change the field names in numpy

a = TableToNumPyArray(in_fc, "*", skip_nulls=True)
flds = a.dtype.names
new_flds = [f"Bati_{i}" for i in flds]
new_flds
 
['Bati_OBJECTID',
 'Bati_Shape',
 'Bati_ids',
 'Bati_CENTROID_X',
 'Bati_CENTROID_Y',
 'Bati_INSIDE_X',
 'Bati_INSIDE_Y',
 'Bati_PART_COUNT',
 'Bati_PNT_COUNT',
 'Bati_Sort_',
 'Bati_Shape_Length',
 'Bati_Shape_Area']
# ---
# -- magic time
from arcpy.da import ExtendTable
a.dtype.names = new_flds
sub_arr = a[['Bati_OBJECTID', 'Bati_PART_COUNT']]
ExtendTable(in_fc, "OBJECTID", sub_arr, 'Bati_OBJECTID')

Magic done

extend_table.png

of course you would want a preselected list of fields to produce/slice fields from the main array to make sub_arr.

 

 


... sort of retired...
0 Kudos
khalidechlouchi
New Contributor II

Thank you for your help, I will try this approach.

0 Kudos
DanPatterson
MVP Esteemed Contributor

closed?


... sort of retired...
0 Kudos