<?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: select (and export) each record in an attribute table within a For: loop in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/select-and-export-each-record-in-an-attribute/m-p/1122426#M48628</link>
    <description>&lt;P&gt;once again, THANKS!&amp;nbsp; SplitByAttribute does exactly what I was hoping to accomplish--in a single line; without needing to employ a SearchCursor.&lt;/P&gt;&lt;P&gt;More than 1 thumb up emoji!&lt;/P&gt;&lt;P&gt;Thanks, Dan!&lt;/P&gt;</description>
    <pubDate>Fri, 03 Dec 2021 04:06:35 GMT</pubDate>
    <dc:creator>PhilCrossley1</dc:creator>
    <dc:date>2021-12-03T04:06:35Z</dc:date>
    <item>
      <title>select (and export) each record in an attribute table within a For: loop</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/select-and-export-each-record-in-an-attribute/m-p/1122408#M48623</link>
      <description>&lt;P&gt;Thanks for previous help!&lt;/P&gt;&lt;P&gt;I'm trying to write an ArcPy script that will:&lt;/P&gt;&lt;P&gt;iterate through a feature class consisting of all the counties in a particular state&lt;/P&gt;&lt;P&gt;select each county and create a new feature class consisting of just that boundary&lt;/P&gt;&lt;P&gt;so that I can then use each county's boundary to do a sequence of geoprocessing steps.&lt;/P&gt;&lt;P&gt;I think I need to begin with a SearchCursor, and then iterate through the list of values (County names) it returns, and I can do that (and print out all the county names as a test), but I can't figure out how to insert each countyName into a SelectBy Attribute query, within the for: loop, by referring to the cursor.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far, I have this snipped (preceded by the requisite set up steps, querying for IN Counties etc:&lt;/P&gt;&lt;PRE&gt;fc = &lt;SPAN&gt;r"E:\advAppScripting\testing\tornhazard\Indiana\Indiana.gdb\IN_counties"&lt;BR /&gt;&lt;/SPAN&gt;cursor = arcpy.da.SearchCursor(fc&lt;SPAN&gt;, &lt;/SPAN&gt;[&lt;SPAN&gt;"NAME"&lt;/SPAN&gt;])&lt;BR /&gt;&lt;SPAN&gt;for &lt;/SPAN&gt;row &lt;SPAN&gt;in &lt;/SPAN&gt;cursor:&lt;BR /&gt;    arcpy.MakeFeatureLayer_management(&lt;SPAN&gt;r"E:\advAppScripting\testing\tornhazard\Indiana\Indiana.gdb\IN_counties"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"counties_lyr"&lt;/SPAN&gt;)&lt;BR /&gt;    arcpy.SelectLayerByAttribute_management(&lt;SPAN&gt;"counties_lyr"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"NEW_SELECTION"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""""NAME" = row[0]"""&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I know this WHERE clause is wrong, I just can't figure out what the value needs to be in order to select the county whose name is the first one in the cursor (and then the second, the third, etc) or if I should be going about this some other way....(Note: if I follow the "for row in cursor: with&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;"{0}"&lt;/SPAN&gt;.format(row[&lt;SPAN&gt;0&lt;/SPAN&gt;]&lt;/PRE&gt;&lt;P&gt;, I DO get a list of all the IN_county names, so I think my SearchCursor is functioning correctly.&lt;/P&gt;&lt;P&gt;THanks, Phil&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 01:47:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/select-and-export-each-record-in-an-attribute/m-p/1122408#M48623</guid>
      <dc:creator>PhilCrossley1</dc:creator>
      <dc:date>2021-12-03T01:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: select (and export) each record in an attribute table within a For: loop</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/select-and-export-each-record-in-an-attribute/m-p/1122412#M48624</link>
      <description>&lt;P&gt;One thing that stands out is you are trying to make a feature layer from a row. This is something you cannot do. Instead, there are a couple of ways you could do this (either by modelbuilder or python).&lt;/P&gt;&lt;P&gt;If you want to do this using python, use this instead:&lt;/P&gt;&lt;P&gt;for row in cursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; output_location = (folder path or file gdb location)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; country_name = row[0]&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; arcpy.CreateFeatureclass_management(output_location&lt;/SPAN&gt;&lt;SPAN&gt;, country_name&lt;/SPAN&gt;&lt;SPAN&gt;, "POLYGON"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Do this for every row and it should provide you with what you are trying to get at.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 02:25:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/select-and-export-each-record-in-an-attribute/m-p/1122412#M48624</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2021-12-03T02:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: select (and export) each record in an attribute table within a For: loop</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/select-and-export-each-record-in-an-attribute/m-p/1122415#M48625</link>
      <description>&lt;P&gt;that is what I was trying to do..(turn a row into a fc)..&lt;/P&gt;&lt;P&gt;But, a question: I thought that the CreateFeatureclass_management was only for creating empty feature classes; whereas I want to use the existing geometry of the county polygons (each row in the input fc) to create a new fc that consists of a single polygon).&amp;nbsp; &amp;nbsp;Will the snippet you suggested do that?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 02:35:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/select-and-export-each-record-in-an-attribute/m-p/1122415#M48625</guid>
      <dc:creator>PhilCrossley1</dc:creator>
      <dc:date>2021-12-03T02:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: select (and export) each record in an attribute table within a For: loop</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/select-and-export-each-record-in-an-attribute/m-p/1122419#M48626</link>
      <description>&lt;P&gt;you could shorten your script if you are splitting based on an attribute (counties)&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/analysis/split-by-attributes.htm" target="_blank"&gt;Split By Attributes (Analysis)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 02:59:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/select-and-export-each-record-in-an-attribute/m-p/1122419#M48626</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-12-03T02:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: select (and export) each record in an attribute table within a For: loop</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/select-and-export-each-record-in-an-attribute/m-p/1122426#M48628</link>
      <description>&lt;P&gt;once again, THANKS!&amp;nbsp; SplitByAttribute does exactly what I was hoping to accomplish--in a single line; without needing to employ a SearchCursor.&lt;/P&gt;&lt;P&gt;More than 1 thumb up emoji!&lt;/P&gt;&lt;P&gt;Thanks, Dan!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 04:06:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/select-and-export-each-record-in-an-attribute/m-p/1122426#M48628</guid>
      <dc:creator>PhilCrossley1</dc:creator>
      <dc:date>2021-12-03T04:06:35Z</dc:date>
    </item>
  </channel>
</rss>

