Does anyone have a script that turns off fields that are empty?

12-10-2015 09:14 AM
New Contributor II

I am trying to find python code samples that will review a feature class and identify all of the fields that are empty and turn their visibility off.

0 Kudos
4 Replies
MVP Regular Contributor


I would suggest moving this to Python

Regular Contributor II

I'm assuming that you want to change the visibility of the fields within the attribute table. If you wanted to modify this value against an existing layer you'd probably need to utilize ArcObjects and the code would center around the following logic.

ILayerFields layerFields = (ILayerFields) layer;

for (int i = 0; i < layerFields.FieldCount; i++)
    layerFields.FieldInfo.Visible = false;

If you want to create a new layer then you'd probably want to leverage a tool that would allow you to utilize a FieldInfo object.


Make Feature Layer

Make Table View

New Contributor III

Can you tell us what you mean by having your fields empty?  Does this mean for all records the value is NULL? or something else?

0 Kudos
New Contributor II

yes.  I have a whole gdb schema that users load data into.  if they don't have any data load into a particular field they just leave it blank, but some of the features have 40 fields and 10 will be empty.  it doesn't show well in web apps when in the attribute table or popup there are all of these fields with no values in them.  thank you everyone that is helping.

0 Kudos