joldekop

Problem Executing Loop

Discussion created by joldekop on Sep 23, 2011
Latest reply on Sep 23, 2011 by mstead
Hello,

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...

cheers,

Johan

Import Phython functions
import arcpy
from arcpy import env
from arcpy.sa import *

env.workspace = "C:/GTZ Data/PEN_IUCN/PEN_IUCN"

InShapefile = "C:/IUCN Data/AMPHANURA/AMPHANURA_RBS_Clip.shp"

try:
rows = arcpy.SearchCursor (InShapefile)
row = rows.next()

while row:
id= row.getValue ("FID")
outFC=id + ".shp"
sel = str('"FID" = ' " ' "+id+" ' ")

arcpy.Select_analysis(InShapefile, OutFC, sel)
row = rows.next()

except:

arcpy.AddMessage(arcpy.GetMessages(2))
print arcpy.GetMessages(2)

Parsing error <type 'exceptions.IndentationError'>: expected an indented block (line 2)

Outcomes