<?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 Executing Loop in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/problem-executing-loop/m-p/748403#M57840</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Please wrap your script in code tags so the indentation is preserved. Especially when your problem IS with indentation...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I had a look at the page source. You don't have an indented block after the except clause:&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 23 Sep 2011 13:46:20 GMT</pubDate>
    <dc:creator>Luke_Pinner</dc:creator>
    <dc:date>2011-09-23T13:46:20Z</dc:date>
    <item>
      <title>Problem Executing Loop</title>
      <link>https://community.esri.com/t5/python-questions/problem-executing-loop/m-p/748401#M57838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;New to python and writing my first scripts. I am trying to build a loop to generate individual polygon shapefiles from a feature layer which contains a whole series of polygons. Here's the script, which doesn't seem to work as well as the error message. I'd be grateful if anyone has any suggestions...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Johan&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; Import Phython functions&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy.sa import *&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = "C:/GTZ Data/PEN_IUCN/PEN_IUCN"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;InShapefile = "C:/IUCN Data/AMPHANURA/AMPHANURA_RBS_Clip.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; rows = arcpy.SearchCursor (InShapefile)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; row = rows.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; while row:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; id= row.getValue ("FID")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; outFC=id + ".shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; sel = str('"FID" = ' " ' "+id+" ' ")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; arcpy.Select_analysis(InShapefile, OutFC, sel)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; row = rows.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;except:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage(arcpy.GetMessages(2))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print arcpy.GetMessages(2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Parsing error &amp;lt;type 'exceptions.IndentationError'&amp;gt;: expected an indented block (line 2)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Sep 2011 10:20:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-executing-loop/m-p/748401#M57838</guid>
      <dc:creator>JohanOldekop</dc:creator>
      <dc:date>2011-09-23T10:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: Problem Executing Loop</title>
      <link>https://community.esri.com/t5/python-questions/problem-executing-loop/m-p/748402#M57839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;&lt;BLOCKQUOTE&gt;joldekop;136108 wrote:&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;.....&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; while row:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; id= row.getValue ("FID")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; outFC=id + ".shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; sel = str('"FID" = ' " ' "+id+" ' ")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; arcpy.Select_analysis(InShapefile, OutFC, sel)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; row = rows.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt; indent block 2! (after while row:)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using "Pyscripter" to write my scripts. If you forget to indent code there, it's marked as an error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Sep 2011 10:44:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-executing-loop/m-p/748402#M57839</guid>
      <dc:creator>VeraDiaz-Köhli</dc:creator>
      <dc:date>2011-09-23T10:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problem Executing Loop</title>
      <link>https://community.esri.com/t5/python-questions/problem-executing-loop/m-p/748403#M57840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Please wrap your script in code tags so the indentation is preserved. Especially when your problem IS with indentation...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I had a look at the page source. You don't have an indented block after the except clause:&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Sep 2011 13:46:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-executing-loop/m-p/748403#M57840</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2011-09-23T13:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: Problem Executing Loop</title>
      <link>https://community.esri.com/t5/python-questions/problem-executing-loop/m-p/748404#M57841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; Hello,&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;New to python and writing my first scripts. I am trying to build a loop to generate individual polygon shapefiles from a feature layer which contains a whole series of polygons. Here's the script, which doesn't seem to work as well as the error message. I'd be grateful if anyone has any suggestions...&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;cheers,&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;Johan&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt; Import Phython functions&amp;nbsp; &lt;BR /&gt;import arcpy&amp;nbsp; &lt;BR /&gt;from arcpy import env&amp;nbsp; &lt;BR /&gt;from arcpy.sa import *&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;env.workspace = "C:/GTZ Data/PEN_IUCN/PEN_IUCN"&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;InShapefile = "C:/IUCN Data/AMPHANURA/AMPHANURA_RBS_Clip.shp"&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;try:&amp;nbsp; &lt;BR /&gt; rows = arcpy.SearchCursor (InShapefile)&amp;nbsp; &lt;BR /&gt; row = rows.next()&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; while row:&amp;nbsp; &lt;BR /&gt; id= row.getValue ("FID")&amp;nbsp; &lt;BR /&gt; outFC=id + ".shp"&amp;nbsp; &lt;BR /&gt; sel = str('"FID" = ' " ' "+id+" ' ")&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; arcpy.Select_analysis(InShapefile, OutFC, sel)&amp;nbsp; &lt;BR /&gt; row = rows.next()&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;except:&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;arcpy.AddMessage(arcpy.GetMessages(2))&amp;nbsp; &lt;BR /&gt;print arcpy.GetMessages(2)&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt; &lt;SPAN style="color:&amp;quot;red&amp;quot;;"&gt;Parsing error &amp;lt;type 'exceptions.IndentationError'&amp;gt;: expected an indented block (line 2)&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note also that you are creating shapefiles that will be numeric.shp... starting a shapefile with a number generally makes ArcMap sad.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try also: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; id= row.getValue ("FID")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; outFC="shape_" + str(id) + ".shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; sel = str('"FID" = ' " ' "+id+" ' ")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Sep 2011 20:23:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-executing-loop/m-p/748404#M57841</guid>
      <dc:creator>JamesHood</dc:creator>
      <dc:date>2011-09-23T20:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problem Executing Loop</title>
      <link>https://community.esri.com/t5/python-questions/problem-executing-loop/m-p/748405#M57842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Arcmap is moody in general, somedays it might smile at numeric.shp.....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What is that first line anyways? "Import Phython Functions"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Sep 2011 21:08:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-executing-loop/m-p/748405#M57842</guid>
      <dc:creator>MichaelStead</dc:creator>
      <dc:date>2011-09-23T21:08:30Z</dc:date>
    </item>
  </channel>
</rss>

