Hi
I am trying to write a code that uses “arcpy.CopyFeatures_management” to copy all feature classes inside an Enterprise geodatabase to a Geodatabase.
The issue here happens when using FOR loop to copy the whole list of F.C’s to the geodatabase, I am trying to assign the same name for the features. But it seems that there is something that I am missing.
I tried different statements for “out_feature_class” with no luck, sometimes the code fails to run or it copies a single F.C only.
<SPAN class="keyword token">import</SPAN> arcpy <SPAN class="punctuation token">,</SPAN>sys
adminconn<SPAN class="operator token">=</SPAN>r<SPAN class="string token">'C:\1\b2.sde'</SPAN>
gdbFile<SPAN class="operator token">=</SPAN>r<SPAN class="string token">'c:\1\x.gdb'</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace<SPAN class="operator token">=</SPAN>adminconn
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>overwriteOutput<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN>
SDEfcList<SPAN class="operator token">=</SPAN>arcpy<SPAN class="punctuation token">.</SPAN>ListFeatureClasses<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace<SPAN class="operator token">=</SPAN>gdbFile
<SPAN class="keyword token">for</SPAN> dataitem <SPAN class="keyword token">in</SPAN> SDEfcList<SPAN class="punctuation token">:</SPAN>
fcdesc <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Describe<SPAN class="punctuation token">(</SPAN>dataitem<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CopyFeatures_management<SPAN class="punctuation token">(</SPAN>dataitem<SPAN class="punctuation token">,</SPAN>gdbFile<SPAN class="operator token">+</SPAN>fcdesc<SPAN class="punctuation token">.</SPAN>name<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></SPAN><SPAN></SPAN></SPAN>
Thanks