<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Python script to copy datasets from arcsde to another gdb in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-script-to-copy-datasets-from-arcsde-to/m-p/1198465#M65145</link>
    <description>&lt;P&gt;My goal is to copy a dataset from arcsde to a file gdb. I have created a gdb with the name of current date of the system just to maintain the archive of&amp;nbsp; gdbs. I am trying to copy the dataset with specified name and copying that to the newly created gdb. My code is as follows which giving me the error pasted at the bottom:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; today=date.today()&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; d4 = today.strftime("%b_%d_%Y")&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; arcpy.CreateFileGDB_management("D:\Data",'{}'.format(d4))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; outpath = r'D:\Data\{}'.format(d4) + ".gdb"&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; list=arcpy.ListDatasets()&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; for b in list:&lt;BR /&gt;... if b == 'CONSDATA.NC_COM':&lt;BR /&gt;... output = outpath + os.sep + b&lt;BR /&gt;... arcpy.CopyFeatures_management(b,output)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Runtime error Traceback (most recent call last): File "&amp;lt;string&amp;gt;", line 4, in &amp;lt;module&amp;gt; File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\management.py", line 2574, in CopyFeatures raise e ExecuteError: ERROR 000732: Input Features: Dataset CONSDATA.NC_COM does not exist or is not supported.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Aug 2022 12:59:59 GMT</pubDate>
    <dc:creator>junaidjawaid</dc:creator>
    <dc:date>2022-08-02T12:59:59Z</dc:date>
    <item>
      <title>Python script to copy datasets from arcsde to another gdb</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-copy-datasets-from-arcsde-to/m-p/1198465#M65145</link>
      <description>&lt;P&gt;My goal is to copy a dataset from arcsde to a file gdb. I have created a gdb with the name of current date of the system just to maintain the archive of&amp;nbsp; gdbs. I am trying to copy the dataset with specified name and copying that to the newly created gdb. My code is as follows which giving me the error pasted at the bottom:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; today=date.today()&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; d4 = today.strftime("%b_%d_%Y")&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; arcpy.CreateFileGDB_management("D:\Data",'{}'.format(d4))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; outpath = r'D:\Data\{}'.format(d4) + ".gdb"&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; list=arcpy.ListDatasets()&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; for b in list:&lt;BR /&gt;... if b == 'CONSDATA.NC_COM':&lt;BR /&gt;... output = outpath + os.sep + b&lt;BR /&gt;... arcpy.CopyFeatures_management(b,output)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Runtime error Traceback (most recent call last): File "&amp;lt;string&amp;gt;", line 4, in &amp;lt;module&amp;gt; File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\management.py", line 2574, in CopyFeatures raise e ExecuteError: ERROR 000732: Input Features: Dataset CONSDATA.NC_COM does not exist or is not supported.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 12:59:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-copy-datasets-from-arcsde-to/m-p/1198465#M65145</guid>
      <dc:creator>junaidjawaid</dc:creator>
      <dc:date>2022-08-02T12:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to copy datasets from arcsde to another gdb</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-copy-datasets-from-arcsde-to/m-p/1198566#M65147</link>
      <description>&lt;P&gt;You need to iterate over the featureclasses in that dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for b in list:
    if b == 'CONSDATA.NC_COM':
        for fc in arcpy.ListFeatureClasses(feature_dataset=b):
            fc_path = os.path.join(arcpy.env.workspace, b, fc)
            output = outpath + os.sep + fc
            arcpy.CopyFeatures_management(fc_path, output)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 15:17:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-copy-datasets-from-arcsde-to/m-p/1198566#M65147</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T15:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to copy datasets from arcsde to another gdb</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-copy-datasets-from-arcsde-to/m-p/1198825#M65154</link>
      <description>&lt;P&gt;Hi jeffK, thanks for the answer.&amp;nbsp; It did work however it is copying the feature classes in the GDB without the dataset. Is there any way to copy the complete dataset with the feature classes within that?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 05:37:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-copy-datasets-from-arcsde-to/m-p/1198825#M65154</guid>
      <dc:creator>junaidjawaid</dc:creator>
      <dc:date>2022-08-03T05:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to copy datasets from arcsde to another gdb</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-copy-datasets-from-arcsde-to/m-p/1198891#M65155</link>
      <description>&lt;P&gt;My bad!&amp;nbsp; To do to the dataset, you need to create one first and then add it in the output path.&lt;/P&gt;&lt;P&gt;edited to add a check for the existence of the dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for b in list:
    if b == 'CONSDATA.NC_COM':
        # check if the dataset already exists and create it if it does not.
        output_ds = os.path.join(outpath, ds)
        if not arcpy.Exists(output_ds):
            # get the spatial reference of the old one to use in the new one
            spatial_ref = arcpy.Describe(b).spatialReference
            # create new ds
            arcpy.management.CreateFeatureDataset(outpath, b, spatial_ref)
        
        # transfer the fcs.
        for fc in arcpy.ListFeatureClasses(feature_dataset=b):
            fc_path = os.path.join(arcpy.env.workspace, b, fc)
            output = os.path.join(output_ds, fc)
            arcpy.CopyFeatures_management(fc_path, output)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If that is the only dataset that you want, you can skip the list and list iteration and create a more targeted script using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ds = arcpy.ListDatasets('CONSDATA.NC_COM')[0]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 12:01:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-copy-datasets-from-arcsde-to/m-p/1198891#M65155</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-03T12:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to copy datasets from arcsde to another gdb</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-copy-datasets-from-arcsde-to/m-p/1198897#M65156</link>
      <description>&lt;P&gt;Yes! I tried with the similar logic. Thanks a lot. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 12:05:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-copy-datasets-from-arcsde-to/m-p/1198897#M65156</guid>
      <dc:creator>junaidjawaid</dc:creator>
      <dc:date>2022-08-03T12:05:42Z</dc:date>
    </item>
  </channel>
</rss>

