1

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

inputTable="PathtoTable/XYZ.mdb/EasementsScratchSelectedRecords"
inputTableAgain="PathtoTable/XYZ.mdb/EasementsScratchSelectedRecords"

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]]
        insertC.insertRow(newRow)
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'

2
  • 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
    Commented Jun 7, 2017 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. Commented Jun 7, 2017 at 15:07

1 Answer 1

2

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.

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

Your Answer

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

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