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'
-
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 aboveBharath– Bharath2017年06月07日 14:57:32 +00:00Commented 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.Evil Genius– Evil Genius2017年06月07日 15:07:43 +00:00Commented Jun 7, 2017 at 15:07
1 Answer 1
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– JRam2014年08月06日 18:51:41 +00:00Commented Aug 6, 2014 at 18:51