2

I'm having trouble with an error message and can't seem to figure out the reason which, I'm sure is something simple. I have a bit of code listed below:

insertPts = arcpy.da.InsertCursor(newFC, ( "FieldA", "FieldB"))
with arcpy.da.SearchCursor(FC, ("FieldA", "FieldB"),""" "FieldA" IS NOT NULL """) as search:
 for row in search:
 num = row[0]
 rPtsNumber = randint(1, row[0])
 row[0] = rPtsNumber
 PTSid = int(row[1])
 for x in xrange (num):
 insertPts.insertRow((rPtsNumber, PTSid))

the error occurs in the line 'for row in search:'. I though it may be an issue with the where clause however, I tried creating a new feature class based on the where clause criteria and continue to get the error. Thanks for any help you can provide.

asked Aug 15, 2014 at 17:07

1 Answer 1

1

This was a careless mistake on my part, I had been using the wrong FC variable in the search cursor. For this script I have too many variables with like names and confused 2 very important ones.

answered Aug 15, 2014 at 17:33
1
  • 1
    Good to know. Sometime's it's easier to assign your field as variables, that way should you need to re-use the script for different fields all you have to do is change the variable ex. field1 = "NameField" you would only have to change "NameField" Commented Aug 15, 2014 at 17:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.