-2

I am trying to use field calculator to calculate a field based on unique types in another field. I had to go for a for loop to add new values. I have 81 classes and every class should be assigned an unique number. I am getting some error in my method. I do not have prior experience of using python code in field calculator. I am sharing my code blocks.

def u_biotope(x):
    u=list(set(x))
    listbt=[]
    count=0
    for i in u:
        btype = count
        listbt.append(count)
        count=count+1
    return listbt
u_biotope( [BIOT1] )

It shows: A field was not found or unbalanced quotation marks

does anyone have any idea, How could I solve this?

9

In the field calculator, your parser should be set to Python. With "Show Codeblock" checked, your function definition should go in the "Pre-Logic Script Code" and the expression box at the bottom should be populated with:

u_biotype(!BIOT1!)

Your code block should end with the return function as well.

The "Calculate Ranges" example on the ArcGIS help page lays out the python syntax for Calculate Field relatively well.

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.