Hi,
I'm using the ArcGIS Pro Python console (we are using ArcGIS Desktop 10.5 mostly but its copy_management doesn't have the associated_data parameter) in order to try to do the following:
Copy all feature classes under a specific data set in an enterprise geodatabase to a new / existing data set with a specific name in the same database and in the process rename the feature classes using a suffix.
This is the current python code:
suffix <SPAN class="operator token">=</SPAN> <SPAN class="string token">"_imahappysuffix"</SPAN>
in_data <SPAN class="operator token">=</SPAN> <SPAN class="string token">"C:/tempo/pyth/data_owner_connection.sde/db_test.dataowner.mexico"</SPAN>
out_data <SPAN class="operator token">=</SPAN> <SPAN class="string token">"C:/tempo/pyth/data_owner_connection.sde/db_test.dataowner.newdataset"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'C:\tempo\pyth\data_owner_connection.sde'</SPAN>
dss <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListDatasets<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"db_test.dataowner.mexico"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"Feature"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> ds <SPAN class="keyword token">in</SPAN> dss<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> fc <SPAN class="keyword token">in</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListFeatureClasses<SPAN class="punctuation token">(</SPAN>feature_dataset<SPAN class="operator token">=</SPAN>ds<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>Copy_management<SPAN class="punctuation token">(</SPAN>in_data<SPAN class="punctuation token">,</SPAN> out_data<SPAN class="punctuation token">,</SPAN> associated_data<SPAN class="operator token">=</SPAN>fc<SPAN class="operator token">+</SPAN><SPAN class="string token">" FeatureClass "</SPAN><SPAN class="operator token">+</SPAN>fc<SPAN class="operator token">+</SPAN>suffix<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></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>This executes and creates a new dataset named newdataset (if it didn't exist) and then creates a copy of the first feature class with the intended suffix. The second and third feature classes in the origin data set however are only given a _1 suffix in the target data set, how come?
I think something might be wrong with how I use associated_data but I haven't figured out what yet.
In the target data set I'm getting:
db_test.dataowner.mexico_dots_imahappysuffix
db_test.dataowner.mexico_realms_1
db_test.dataowner.mexico_rivers_1
Thanks for reading : )