Hi guys,
I have 54 point files named T1-T54. I have 54 polygons called T__1_ExportFeatures1-54.
I want to join a field from the point file to its corresponding polygon file table. So the field in T1 joins to the table in T__1_ExportFeatures1, the field in T2 joins to the table in T__1_ExportFeatures2, etc. All files are in the same geodatabase folder.
Doing it one by one would be time consuming. I presume its a job for iterate feature classes in model builder, but Im not sure how exactly. I can iterate over all of the polygon feature classes, but I don't know how to pull the corresponding point table for the join.
Any suggestions?
Thanks! Tom
You are correct to look at the Iterate Feature Classes tool. One of its outputs is the file name. You can then use a python expression of function (Calculate Value tool) to generate the corresponding path and then do the join. Join Field may be a better approach than add join / copy features, depending on what you're doing. Here's an example of the calculation to generate the second file name,
# this is an example what you get from the iterator Name output variable
# (data used below in variable reference %Name%)
"T1"
# here is an example of what expression you could
# use with the Calculate Value tool
# this would evaluate to :"T__1_ExportFeatures1"
"T__1_ExportFeatures{}".format("%Name%".replace("T",""))
You then use the output variable from Calculate Value for tools used down the chain, like Join Field.
A tip: if needed, use preconditions, for example, make sure the iterator "Name" variable is set as a precondition to the Calculate Value to make sure you are working with the value from the current iteration.
Hope this is helpful to you!
try this. pls let me know if this works
Thanks ShitijMehta,
Could you post a higher resolution image please?
try now.. U might be able to make the image larger by hovering over the image and clicking once... pls can u check? ty