0

I am trying to insert some variable into a simple arcpy call using .format(var1, var2) as I would in a string. I am new to using Python 3.6, so maybe there's been some change in how this is done. When I run the following, I get a

ERROR 000732: Layer Name or Table View: Dataset '{}' does not exist or is not supported

error, which then causes an Execute Error for bad parameters. What am I doing wrong here?

  select = arcpy.SelectLayerByAttribute_management("'{}'", "NEW_SELECTION", "FIPS_CODE = '{}'").format(name, item)
2

I think that you should try this instead:

arcpy.SelectLayerByAttribute_management("{}".format(name), "NEW_SELECTION", "FIPS_CODE = '{}'".format(item))

If it works, I can explain what you did wrong.

If it does not, then I suggest expanding your code snippet to print variables name and item, before you try to use them.

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.