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

3468
4
12-10-2015 09:14 AM
BobbySells
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
RickeyFight
MVP Regular Contributor

Bobby,

I would suggest moving this to Python

FreddieGibson
Occasional Contributor III

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.

FieldInfo

http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-classes/fieldinfo.htm

Make Feature Layer

http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/make-feature-layer.htm

Make Table View

http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/make-table-view.htm

DarrylKlassen
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
BobbySells
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