Select to view content in your preferred language

How do I remove null values from Maplex Labeling using Python?

3258
11
03-01-2017 11:10 AM
MikeHutchison
Deactivated User

def FindLabel ( [INSERTEDMAINSIZE], [INSERTEDMAINMATERIAL] 😞
  return str([INSERTEDMAINSIZE]) + " " + str([INSERTEDMAINMATERIAL])


I'm using ArcMap 10.2.  There are null values in [INSERTEDMAINSIZE] and [INSERTEDMAINMATERIAL].  Instead of labeling the Null values as "None" I don't want them to show up on the map at all.  If there is a value for that features, I want that to label, just not the null values.  How do I add this to the script?

Thanks

0 Kudos
11 Replies
MikeHutchison
Deactivated User

I don't know man I still can't get it.  It works for my other feature, but for the abandoned feature it's not working.

0 Kudos
RandyBurton
MVP Alum

As Darren is suggesting, try:

def FindLabel ( [MAINSIZE], [MAINMATERIALTYPE], [SYSTEMMAOP], [INSTALLATIONDATE], [WORKORDERNUMBER], [INSERTEDMAINSIZE], [INSERTEDMAINMATERIAL] ):
     return ' '.join(filter(None, ([MAINSIZE],[MAINMATERIALTYPE],[SYSTEMMAOP],'D',([INSTALLATIONDATE][-2:]),[WORKORDERNUMBER], '\n', [INSERTEDMAINSIZE], [INSERTEDMAINMATERIAL])))
‍‍‍‍‍