<?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 feature classes from feature datasets in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-script-to-copy-feature-classes-from-feature/m-p/255049#M19599</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a geodatabase which consists of about 100 feature datasets, and each feature dataset contains 2 to 4 feature classes (Please see an example of my geodatabase and its contents).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Python Script.png" class="image-1 jive-image" src="/legacyfs/online/145590_Python Script.png" style="width: 620px; height: 240px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to copy a polyline feature class (this feature class's file name in every feature dataset starts with "polyline") from every feature dataset to a new geodatabase as stand alone feature class. I want the new feature classes to be renamed as ("polyline_" + the name of the feature dataset). For example if the original feature dataset and feature class are "Dset4" and "Polyline10_3" respectively, the new feature class will have a file name of "Polyline_Dset4". I also want the new feature class to have less number of fields than the original feature class. Can anyone help me in writing the python script that can do these functions? Thanks in advance. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Nov 2015 13:34:59 GMT</pubDate>
    <dc:creator>HabG_</dc:creator>
    <dc:date>2015-11-20T13:34:59Z</dc:date>
    <item>
      <title>Python script to copy feature classes from feature datasets</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-copy-feature-classes-from-feature/m-p/255049#M19599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a geodatabase which consists of about 100 feature datasets, and each feature dataset contains 2 to 4 feature classes (Please see an example of my geodatabase and its contents).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Python Script.png" class="image-1 jive-image" src="/legacyfs/online/145590_Python Script.png" style="width: 620px; height: 240px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to copy a polyline feature class (this feature class's file name in every feature dataset starts with "polyline") from every feature dataset to a new geodatabase as stand alone feature class. I want the new feature classes to be renamed as ("polyline_" + the name of the feature dataset). For example if the original feature dataset and feature class are "Dset4" and "Polyline10_3" respectively, the new feature class will have a file name of "Polyline_Dset4". I also want the new feature class to have less number of fields than the original feature class. Can anyone help me in writing the python script that can do these functions? Thanks in advance. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Nov 2015 13:34:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-copy-feature-classes-from-feature/m-p/255049#M19599</guid>
      <dc:creator>HabG_</dc:creator>
      <dc:date>2015-11-20T13:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to copy feature classes from feature datasets</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-copy-feature-classes-from-feature/m-p/255050#M19600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will want to use &lt;A href="http://pro.arcgis.com/en/pro-app/arcpy/data-access/walk.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;arcpy.da.walk&lt;/A&gt;​ and &lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/functions/listdatasets.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;list datasets &lt;/A&gt;​with a "Feature" dataset type filter and then get a list of polylines using &lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/functions/listfeatureclasses.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;list feature classes&lt;/A&gt;​ with a "Polyline" filter. Then for each polyline you can run &lt;A href="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/copy-features.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Copy Features&lt;/A&gt;​ to copy into your new geodatabase. The &lt;A href="https://docs.python.org/2/library/os.html" rel="nofollow noopener noreferrer" target="_blank"&gt;os &lt;/A&gt;​module would come in handy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something like this would work, but you can adapt it to what you need:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
from arcpy import env

&lt;PRE class="lia-code-sample line-numbers language-none"&gt;env.workspace = "Your geodatabase path"
outputGDB = "The new geodatabase path"

for gdb, datasets, features in arcpy.da.Walk(env.workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for dataset in datasets:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for feature in arcpy.ListFeatureClasses("Polyline_*","POLYLINE",dataset):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(feature,os.path.join(outputGDB,"Polyline_"+dataset)) &lt;/PRE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:36:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-copy-feature-classes-from-feature/m-p/255050#M19600</guid>
      <dc:creator>LukeSturtevant</dc:creator>
      <dc:date>2021-12-11T12:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to copy feature classes from feature datasets</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-copy-feature-classes-from-feature/m-p/255051#M19601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Luke,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is perfect.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Nov 2015 15:07:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-copy-feature-classes-from-feature/m-p/255051#M19601</guid>
      <dc:creator>HabG_</dc:creator>
      <dc:date>2015-11-20T15:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to copy feature classes from feature datasets</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-copy-feature-classes-from-feature/m-p/255052#M19602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The ArcPy Data Access Walk function is robust enough to handle it without involving the ListFeatureClasses function:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
gdb_in = #path to input geodatabase
gdb_out = #path to output geodatabase

walk = arcpy.da.Walk(gdb_in, datatype="FeatureClass", type="Polyline")
for root, dirs, files in walk:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if root != gdb_in:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for f in files: 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; os.path.join(gdb_out,"Polyline_" + os.path.split(root)[1]))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above assumes there is only 1 polyline feature class in each feature dataset, but the name of the polylines feature classes could also be dealt with in the for loop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:36:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-copy-feature-classes-from-feature/m-p/255052#M19602</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T12:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to copy feature classes from feature datasets</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-copy-feature-classes-from-feature/m-p/1044433#M60698</link>
      <description>&lt;P&gt;I am interested in this because I have a similar but slightly different problem. I have multiple geodatabases that I would like to 'walk' through contained in a folder. Each feature dataset and feature class within have the same names as the other feature datasets and feature classes in the other geodatabases. I expanded a few feature datasets below to show this.&lt;/P&gt;&lt;P&gt;How would I go about 'walking' through a workspace that contains multiple geodatabases, copying the feature classes in each and appending the respective geodatabase name to each copied feature class?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SterlingL_0-1617748246982.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/10269i70DC88A4ED7AD675/image-size/large?v=v2&amp;amp;px=999" role="button" title="SterlingL_0-1617748246982.png" alt="SterlingL_0-1617748246982.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 22:35:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-copy-feature-classes-from-feature/m-p/1044433#M60698</guid>
      <dc:creator>SterlingL</dc:creator>
      <dc:date>2021-04-06T22:35:34Z</dc:date>
    </item>
  </channel>
</rss>

