0

This question already has an answer here:

I am trying to edit the basic sequential numbers in a field script using Python in the Field Calculator.

I set the Parser to Python, and for my Pre-logic Script:

rec=0
name="manhole"
def autoIncrement(): 
 global rec 
 pStart = 1  
 pInterval = 1 
 if (rec == 0):  
  rec = pStart  
 else:  
  rec += pInterval  
 return name, rec

And for the box below:

autoIncrement()

Would this not be how to go about this?

Essentially I just want "manhole1" then "manhole2" then "manhole3", etc.

marked as duplicate by PolyGeo May 27 at 11:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    That code will put sequential numbers in the fields. If you want to add manhole to it, and it is a string field, just field calculate "manhole" + "numberfield" – Maksim Jun 27 '18 at 15:33
  • 'Manhole %s' %autoincrement() is one of solutions. Remove name from script. – FelixIP Jun 27 '18 at 19:15
2

A field calculator expression using pre-logic code should have a function called that, in the end, returns a single value each time the function is called. Currently, you are returning two separate values. To return a single value, you should be able to take your code above and change the line from return name, rec to return 'name' + str(rec)

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