I am new to python and am trying to get a string field in a geodatabase table to split and create a new row. Here is the code based on the solution from Splitting strings into new rows, retaining geometry:

import arcpy


searchC =  arcpy.da.SearchCursor(inputTable, ("OBJECTID","DocumentNameorNumber","SecondaryIdentifier")) 

insertC = arcpy.da.InsertCursor(inputTableAgain, ("OBJECTID","DocumentNameorNumber","SecondaryIdentifier")) 

for row in searchC:
    A = [x.split('Point') for x in row[:-1] ]

    for i in range(min(len(A[0]),len(A[1]),len(A[2]))):
        newRow = [A[0][i] , A[1][i], A[2][i], row[3]]
del insertC

I keep getting the following error:

line 17, in A = [str(x.split('Point')) for x in row[:-1] ] AttributeError: 'int' object has no attribute 'split'

  • num1, operator, num2 = input('Enter the calculator operations : ').split() Can some tell me what's wrong with this code. I get the same error mentioned above – Bharath Jun 7 '17 at 14:57
  • Please do not post new questions as answers. Once you gain enough reputation, you'll be able to comment on other posts. Additionally, it looks like your question is really only about Python and not about GIS, so it would belong on Stack Overflow. The answer to this question there is probably along the lines of what you are looking for. – Evil Genius Jun 7 '17 at 15:07

In your code try replacing this:

for row in searchC:
    A = [x.split('Point') for x in row[:-1] ]

with this:

for row in searchC:
    print row[:-1]
    A = [x.split('Point') for x in row[:-1] ]

and I think you will see that row[:-1] is returning a list of integers that you are iterating and then cannot split individually.

  • Thank you. You pin pointed the problem. I was trying to split from the wrong column. Excellent answer! – JRam Aug 6 '14 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.