HI, I'm trying to compare the feature classe in 2 geodatabase, and make an APPEND if the name is the same. I'm trying with WHILE but not work correct. How can I do it?
If then is tricky with ModelBuilder.
I think the most straightforward way to do this is to do the compare with a Python function inside a Calculate Value tool. Have your function return 1 or 0 and make the returned value a precondition to your append operation.
expression
test_same<SPAN class="punctuation token">(</SPAN>r<SPAN class="string token">"%Featureclass1%"</SPAN><SPAN class="punctuation token">,</SPAN> r<SPAN class="string token">"%Featureclass2%"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
code block
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">test_same</SPAN><SPAN class="punctuation token">(</SPAN>fc1<SPAN class="punctuation token">,</SPAN> fc2<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> nm1 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Describe<SPAN class="punctuation token">(</SPAN>fc1<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>name<SPAN class="punctuation token">.</SPAN>lower<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> nm2 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Describe<SPAN class="punctuation token">(</SPAN>fc2<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>name<SPAN class="punctuation token">.</SPAN>lower<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> nm1 <SPAN class="operator token">==</SPAN> nm2<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="number token">1</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="number token">0</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.