Dear all,
I am using ArcMap 10.7.
I am appending successfuly features from one GDB to another GDB, after updating two fields in the original gdb. (1) However, I want to change it.
I want to do the append these features from one GDB to another, and than I want to update the fields of these features in the destination GDB (2). No idea on how to do this. I put the code of the (1) but I need something for the (2)
Anyone can suggest something.
Cheers
P
<SPAN class="punctuation token">(</SPAN>…<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> fc <SPAN class="keyword token">in</SPAN> fcs<SPAN class="punctuation token">:</SPAN>
count<SPAN class="operator token">=</SPAN>count_records<SPAN class="punctuation token">(</SPAN>fc<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># counts the features within each FC</SPAN>
<SPAN class="keyword token">if</SPAN> count<SPAN class="operator token"><></SPAN><SPAN class="string token">"0"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="comment token"># only feature classes with features</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN>fc<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> fc
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>fc<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"DATE_1"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> cur <SPAN class="punctuation token">:</SPAN> <SPAN class="comment token">## rewrite the date in the field</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> cur<SPAN class="punctuation token">:</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="operator token">=</SPAN>date
cur<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">del</SPAN> row
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>fc<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"PED"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> cursor_Name<SPAN class="punctuation token">:</SPAN> <SPAN class="comment token">#update the Issue_Name field in the Feature classes that have features, with the latest date</SPAN>
<SPAN class="keyword token">print</SPAN> issue_code
<SPAN class="keyword token">for</SPAN> prow <SPAN class="keyword token">in</SPAN> cursor_Name<SPAN class="punctuation token">:</SPAN>
prow<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="operator token">=</SPAN>issue_code
cursor_Name<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>prow<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">del</SPAN> prow
targetfc <SPAN class="operator token">=</SPAN> GDBDwgs <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\"</SPAN> <SPAN class="operator token">+</SPAN> fc
<SPAN class="keyword token">print</SPAN> targetfc
<SPAN class="keyword token">try</SPAN><SPAN class="punctuation token">:</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>Append_management<SPAN class="punctuation token">(</SPAN>fc<SPAN class="punctuation token">,</SPAN>targetfc<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"NO_TEST"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">""</SPAN> <SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">except</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"something went wrong"</SPAN>
<SPAN class="keyword token">del</SPAN> cur
<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></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>