I'm working on writing a script that will calculate facility ID's for feature classes in a feature dataset. Is there a way to do this without making feature layers and doing select/field calculate operations on all of them?

Basically, I'm wanting to iterate through the feature dataset and create a list of feature classes that can then have the field calc ran on each. The problem is that each feature class has a different expression for field calculation, and I need to select only null values, and the select layer by attribute function requires a feature layer.

  • 1
    It's not hard to make a feature layer from a feature class, read resources.arcgis.com/en/help/main/10.2/index.html#//… about MakeFeatureLayer. Your question is a little to vague to be helpful in any specific way; are you looking for a particular field that has Null values? Making a feature layer with a where clause '<field> is NULL' coupled with int(arcpy.GetCount_management(YourFeatureLayer).getOutput(0)) will very quickly give you an idea of how many features have a null in their <field>. Jul 3, 2018 at 3:11
  • Make an attempt using da.UpdateCursor and post a new question if you get stuck and include your code attempt.
    – BERA
    Jul 3, 2018 at 8:03
  • I just need to calculate facility ID's for every feature class in a feature dataset, all using a common field. The problem is that each feature class has a different method if calculating the ID's. I'll try the update cursor. Thanks, guys! Jul 3, 2018 at 12:06

1 Answer 1


I would not use the Field Calculator for this. Instead I would use an arcpy.da.UpdateCursor():

UpdateCursor establishes read-write access to records returned from a feature class or table.

Returns an iterator of lists. The order of values in the list matches the order of fields specified by the field_names argument.

You will need to write various if/elif/else statements, use ListFeatureClasses, etc to complete your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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