<?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 Re: Problem running arcpy.CopyFeatures using arcpy.da.SearchCursor in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/problem-running-arcpy-copyfeatures-using-arcpy-da/m-p/161915#M12393</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmmm, that's tricky. Maybe the &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/index.html#//000800000005000000" rel="nofollow" target="_blank"&gt;Select_analysis&lt;/A&gt;&lt;SPAN&gt; would work better:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;sql = '"' + field1 + '"' + ' = ' + str(int(row[0])) arcpy.Select_analysis(Input_Point_Layer, rowBasePoint,sql)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If that doesn't work, I might you might need a different sql statement (because you're using a '.gdb'). Try this too:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;sql = '[' + field1 + ']' + ' = ' + str(int(row[0])) arcpy.Select_analysis(Input_Point_Layer, rowBasePoint,sql)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know how it goes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Apr 2014 16:35:35 GMT</pubDate>
    <dc:creator>JoshuaChisholm</dc:creator>
    <dc:date>2014-04-22T16:35:35Z</dc:date>
    <item>
      <title>Problem running arcpy.CopyFeatures using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/problem-running-arcpy-copyfeatures-using-arcpy-da/m-p/161912#M12390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I'm trying to run the following script using python that uses the 10.1 introduced arcpy.da.SearchCursor (with a group by sql clause) to run over a feature layer, select two features with the same field value (hence the group by), export the current features to an outside feature layer, and then calculate a route (using network analyst) between the two point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The PROBLEM(for now, at least): &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;when the script runs the arcpy.CopyFeatures, the script fails. I suspect that it is due to the the input features - that row is not a valid input feature. But there I'm stuck, what should I put instead? Am I right in the diagnosis? what can I do to solve it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; import arcpy&amp;nbsp; # Check out any necessary licenses arcpy.CheckOutExtension("Network")&amp;nbsp;&amp;nbsp; # Script arguments Field_To_Group_By = arcpy.GetParameterAsText(0) if Field_To_Group_By == '#' or not Field_To_Group_By: &amp;nbsp;&amp;nbsp;&amp;nbsp; Field_To_Group_By = "myID" #" # provide a default value if unspecified&amp;nbsp; Input_Point_Layer = arcpy.GetParameterAsText(1) if Input_Point_Layer == '#' or not Input_Point_Layer: &amp;nbsp;&amp;nbsp;&amp;nbsp; Input_Point_Layer = "D:\\Projects\\A\\MyDefaultGDB.gdb\\MyDefaultInput" # provide a default value if unspecified&amp;nbsp; # Local variables: FTGB = Field_To_Group_By Add_Locations_Output_Layer = FTGB&amp;nbsp; Solved_Layer = Add_Locations_Output_Layer Routes = Solved_Layer route__Value_ = Routes Route__Name___2 = route__Value_ Route__Name___3 = Route__Name___2 totals__2_ = Route__Name___3 Solve_Succeeded = Add_Locations_Output_Layer Value = Field_To_Group_By BasePointsResult = "D:\\Projects\\A\\BasePoints.gdb\\" net_ND = "D:\\Projects\\A\\MyRoute.gdb\\net\\net_ND" totals = "D:\\Projects\\A\\SumsOfRoutes.gdb\\totals" Make_Route_Result_Layer = "Route"&amp;nbsp; count = 0 field1 = "myID" sql = [None,"GROUP BY myID,&amp;nbsp; OBJECTID"] currObj =&amp;nbsp; arcpy.da.SearchCursor(Input_Point_Layer,field1,sql_clause=sql)&amp;nbsp; try: &amp;nbsp;&amp;nbsp;&amp;nbsp; for row in currObj: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowBasePoint = BasePointsResult + "basePoints_" + str(int(row[0])) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print count &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Make Route Layer &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeRouteLayer_na(net_ND, "Route", "Seconds")#, "USE_INPUT_ORDER", "PRESERVE_BOTH", "NO_TIMEWINDOWS", "", "ALLOW_UTURNS", "Oneway", "NO_HIERARCHY", "", "TRUE_LINES_WITH_MEASURES", "") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "MakeRouteLayer"&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print row &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Copy Features - create BasePoints &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(row, rowBasePoint )#, "", "0", "0", "0") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "basePoints_" + str(int(row[0])) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Copy Features -basepoints"&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Add Locations &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddLocations_na(Make_Route_Result_Layer, "Stops", row, "Name # #;Attr_Length # 0", "5000 Meters", "", "Roads SHAPE;net_ND_Junctions NONE", "MATCH_TO_CLOSEST", "APPEND", "SNAP", "30 Meters", "EXCLUDE", "Roads&amp;nbsp; #;net_ND_Junctions #") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Add Locations"&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Solve &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Solve_na(Add_Locations_Output_Layer, "SKIP", "CONTINUE", "")&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Select Data &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectData_management(Solved_Layer, "Routes")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Apr 2014 13:46:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-running-arcpy-copyfeatures-using-arcpy-da/m-p/161912#M12390</guid>
      <dc:creator>yonatanrubinstein</dc:creator>
      <dc:date>2014-04-22T13:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: Problem running arcpy.CopyFeatures using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/problem-running-arcpy-copyfeatures-using-arcpy-da/m-p/161913#M12391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think your diagnosis is correct. You'll have to create a feature layer and export that instead of the row. Assuming "myID" is unique, this should work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;sql = '"' + field1 + '"' + ' = ' + str(int(row[0])) #use this line if myID is a number (and remove the other line)
sql = '"' + field1 + '"' + ' = ' + "'" + str(int(row[0])) +"'" #use this line if myID is a text (and remove the other line)
arcpy.MakeFeatureLayer_management(Input_Point_Layer, "selection", sql)
arcpy.CopyFeatures_management("selection", rowBasePoint)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;(insert this code where the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;arcpy.CopyFeatures_management&lt;/SPAN&gt;&lt;SPAN&gt; line is)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know how it goes. Good luck!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:30:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-running-arcpy-copyfeatures-using-arcpy-da/m-p/161913#M12391</guid>
      <dc:creator>JoshuaChisholm</dc:creator>
      <dc:date>2021-12-11T08:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Problem running arcpy.CopyFeatures using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/problem-running-arcpy-copyfeatures-using-arcpy-da/m-p/161914#M12392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I think your diagnosis is correct. You'll have to create a feature layer and export that instead of the row. Assuming "myID" is unique, this should work:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;sql = '"' + field1 + '"' + ' = ' + str(int(row[0])) #use this line if myID is a number (and remove the other line)
sql = '"' + field1 + '"' + ' = ' + "'" + str(int(row[0])) +"'" #use this line if myID is a text (and remove the other line)
arcpy.MakeFeatureLayer_management(Input_Point_Layer, "selection", sql)
arcpy.CopyFeatures_management("selection", rowBasePoint)&lt;/PRE&gt;&lt;BR /&gt;(insert this code where the &lt;SPAN style="font-style:italic;"&gt;arcpy.CopyFeatures_management&lt;/SPAN&gt; line is)&lt;BR /&gt;&lt;BR /&gt;Let me know how it goes. Good luck!&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Joshua, thanks for answering. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did as you wrote (in my case the myID is a number), but it made a feature class consisting of all the features in the original fc, and not just the ones selected by the "row". Any IDEAS?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:30:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-running-arcpy-copyfeatures-using-arcpy-da/m-p/161914#M12392</guid>
      <dc:creator>yonatanrubinstein</dc:creator>
      <dc:date>2021-12-11T08:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: Problem running arcpy.CopyFeatures using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/problem-running-arcpy-copyfeatures-using-arcpy-da/m-p/161915#M12393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmmm, that's tricky. Maybe the &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/index.html#//000800000005000000" rel="nofollow" target="_blank"&gt;Select_analysis&lt;/A&gt;&lt;SPAN&gt; would work better:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;sql = '"' + field1 + '"' + ' = ' + str(int(row[0])) arcpy.Select_analysis(Input_Point_Layer, rowBasePoint,sql)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If that doesn't work, I might you might need a different sql statement (because you're using a '.gdb'). Try this too:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;sql = '[' + field1 + ']' + ' = ' + str(int(row[0])) arcpy.Select_analysis(Input_Point_Layer, rowBasePoint,sql)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know how it goes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Apr 2014 16:35:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-running-arcpy-copyfeatures-using-arcpy-da/m-p/161915#M12393</guid>
      <dc:creator>JoshuaChisholm</dc:creator>
      <dc:date>2014-04-22T16:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: Problem running arcpy.CopyFeatures using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/problem-running-arcpy-copyfeatures-using-arcpy-da/m-p/161916#M12394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Simply put, you should never try to export or make layers or copy feature classes inside a cursor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That is not what cursors are for.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Exporting a geometry object is something else, but that is far to complex a solution for your need.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Use the search cursor to get a list of the unique vaues in the myID field&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;myIdList = []
cur = arcpy.da.SearchCursor(Input_Point_Layer,field1)
for row in cur:
&amp;nbsp;&amp;nbsp;&amp;nbsp; myID = row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; if myID not in myIdList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myIdList.append(myID)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;now loop through the list; making layers of, and copying out features with, each myId value:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for my in myIdList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; outLayer = "outLayer"
&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists(outLayer):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(outLayer)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; newFC = r"%s\out_%s" % (pathVar, my)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists(newFC):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(newFC)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; where = "\"myID\" = '%s'" % (my)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(Input_Point_Layer,
&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outLayer,
&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where)
&amp;nbsp;&amp;nbsp;&amp;nbsp; CopyFeatures_management(outLayer, newFC)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:30:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-running-arcpy-copyfeatures-using-arcpy-da/m-p/161916#M12394</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2021-12-11T08:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Problem running arcpy.CopyFeatures using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/problem-running-arcpy-copyfeatures-using-arcpy-da/m-p/161917#M12395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hmmm, that's tricky. Maybe the &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//000800000005000000" rel="nofollow noopener noreferrer" target="_blank"&gt;Select_analysis&lt;/A&gt; would work better:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;sql = '"' + field1 + '"' + ' = ' + str(int(row[0]))
arcpy.Select_analysis(Input_Point_Layer, rowBasePoint,sql)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;If that doesn't work, I might you might need a different sql statement (because you're using a '.gdb'). Try this too:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;sql = '[' + field1 + ']' + ' = ' + str(int(row[0]))
arcpy.Select_analysis(Input_Point_Layer, rowBasePoint,sql)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Let me know how it goes.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Joshua , Sorry for the late reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your Idea worked beautifully, when I used Select_Analysis instead of CopyFeatures. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:30:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-running-arcpy-copyfeatures-using-arcpy-da/m-p/161917#M12395</guid>
      <dc:creator>yonatanrubinstein</dc:creator>
      <dc:date>2021-12-11T08:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problem running arcpy.CopyFeatures using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/problem-running-arcpy-copyfeatures-using-arcpy-da/m-p/161918#M12396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Simply put, you should never try to export or make layers or copy feature classes inside a cursor.&lt;BR /&gt;That is not what cursors are for.&lt;BR /&gt;Exporting a geometry object is something else, but that is far to complex a solution for your need.&lt;BR /&gt;&lt;BR /&gt;Use the search cursor to get a list of the unique vaues in the myID field&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;myIdList = []
cur = arcpy.da.SearchCursor(Input_Point_Layer,field1)
for row in cur:
&amp;nbsp;&amp;nbsp;&amp;nbsp; myID = row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; if myID not in myIdList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myIdList.append(myID)&lt;/PRE&gt;&lt;BR /&gt;now loop through the list; making layers of, and copying out features with, each myId value:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for my in myIdList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; outLayer = "outLayer"
&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists(outLayer):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(outLayer)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; newFC = r"%s\out_%s" % (pathVar, my)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists(newFC):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(newFC)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; where = "\"myID\" = '%s'" % (my)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(Input_Point_Layer,
&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outLayer,
&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where)
&amp;nbsp;&amp;nbsp;&amp;nbsp; CopyFeatures_management(outLayer, newFC)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark, I know that cursors "are not meant" for this, but a. it works. b. I didn't find any other way, I would appriciate it if you show me a different way. The two loops you presented are not good enough - I want a single loop, as I loop over a table of 150,000 lines and want it to be quick...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:30:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-running-arcpy-copyfeatures-using-arcpy-da/m-p/161918#M12396</guid>
      <dc:creator>yonatanrubinstein</dc:creator>
      <dc:date>2021-12-11T08:30:16Z</dc:date>
    </item>
  </channel>
</rss>

