0
filter = 'LinkID IS NOT NULL' 
cur1 = arcpy.UpdateCursor("ODDS_Links", filter) 

high_id = 0
for row1 in cur1:
 if high_id < row1.LinkID:
  high_id = row1.LinkID



filter2 = 'LinkID IS NULL' 
cur2 = arcpy.UpdateCursor("ODDS_Links", filter2)

i = high_id
for row2 in cur2:
 i+=1
 row2.LinkID = str(i) 
 cur2.updateRow(row2) 

The error I am getting is below. I know this works without the counter but something is wrong with counter and it won't add by one. If I comment out the counter it displays the error. I know I should use da but really don't feel like changing things around when I am so close.

TypeError: coercing to Unicode: need string or buffer, int found

  • What is the data type of LinkID? – dklassen Jul 23 '14 at 18:36
  • Is your 2nd cursor supposed to be in the loop of the first? Also, yes, you should swap to da. – Paul Jul 23 '14 at 18:38
  • No it is 2 separate loops – nicholas hetrick Jul 23 '14 at 18:39
  • LinkID is a string currently. I will test with an int thanks. I thought that may be an issue. – nicholas hetrick Jul 23 '14 at 18:50
  • Yes it was the data type that was the issue switching to an int solved the issue. Thanks @dklassen – nicholas hetrick Jul 23 '14 at 19:08
1

Yes it was the data type that was the issue.

On advice of @dklassen switching the value passed to LinkID to an int data type solved the issue.

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.