# Remove Empty Items from Lists

**URL:** <https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594>\
**Category:** Grasshopper\
**Created:** [June 11, 2019, 10:03am UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594 "2019-06-11T10:03:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![osuire](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/osuire/32/656689_2.png) [@osuire](https://discourse.mcneel.com/u/osuire)\
**Post date:** [June 11, 2019, 10:03am UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/1 "2019-06-11T10:03:30Z")

</div>

These critters are as pesky as Nulls, there should be specific commands to get rid of them or to replace them by a some value, or maybe adding this as an option to “Null item” and “Replace Nulls”, like what is done with “Clean Tree”.

I know about using textlenght as a hack to do this, but it is just that : a hack.

---

<div class="post-metadata">

**Author:** ![Adam\_M](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/adam_m/32/769331_2.png) [@Adam\_M](https://discourse.mcneel.com/u/Adam_M)\
**Post date:** [June 11, 2019, 11:17am UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/2 "2019-06-11T11:17:03Z")

</div>

I’d like to see this option too.

Another hack could be to replace empties with nulls, and then replace using the usual methods.

[EmptyToNull.gh (5.9 KB)](https://discourse.mcneel.com/uploads/short-url/xG8lwapbJRjLavw3oUgYAvXmUGP.gh)  
 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/f/4/f48213e7a0fa1b23a151bb904615b118d0a586e1.png)

---

<div class="post-metadata">

**Author:** ![Michael\_Pryor](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/michael_pryor/32/489117_2.png) [@Michael\_Pryor](https://discourse.mcneel.com/u/Michael_Pryor)\
**Post date:** [June 11, 2019, 1:03pm UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/3 "2019-06-11T13:03:13Z")

</div>

Uhhh, clean tree component has a remove empty input. Make it true. 😃

---

<div class="post-metadata">

**Author:** ![Adam\_M](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/adam_m/32/769331_2.png) [@Adam\_M](https://discourse.mcneel.com/u/Adam_M)\
**Post date:** [June 11, 2019, 1:08pm UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/4 "2019-06-11T13:08:33Z")

</div>

I thought the idea was to replace empty items, not just clean.

---

<div class="post-metadata">

**Author:** ![Michael\_Pryor](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/michael_pryor/32/489117_2.png) [@Michael\_Pryor](https://discourse.mcneel.com/u/Michael_Pryor)\
**Post date:** [June 11, 2019, 1:11pm UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/5 "2019-06-11T13:11:19Z")

</div>

`there should be specific commands to get rid of them or to replace`

Get rid of is stated.

Additionally, I might be wrong about this, but I think replace nulls also can replace empty by just plugging that list in without the python. Not at a computer at the moment. Could be terribly wrong.

---

<div class="post-metadata">

**Author:** ![Adam\_M](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/adam_m/32/769331_2.png) [@Adam\_M](https://discourse.mcneel.com/u/Adam_M)\
**Post date:** [June 11, 2019, 1:19pm UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/6 "2019-06-11T13:19:02Z")

</div>

Oops. I focused on replace, since clean already gets rid of empties.

I tried replace nulls for empties, but it doesn’t seem to work…unless I’m missing something.

---

<div class="post-metadata">

**Author:** ![Michael\_Pryor](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/michael_pryor/32/489117_2.png) [@Michael\_Pryor](https://discourse.mcneel.com/u/Michael_Pryor)\
**Post date:** [June 11, 2019, 1:19pm UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/7 "2019-06-11T13:19:31Z")

</div>

Then I probably just imagined it.

---

<div class="post-metadata">

**Author:** ![mattgaydon](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/mattgaydon/32/770786_2.png) [@mattgaydon](https://discourse.mcneel.com/u/mattgaydon)\
**Post date:** [June 11, 2019, 1:20pm UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/8 "2019-06-11T13:20:58Z")

</div>

@Michael_Pryor

Neither Clean tree or Replace Nulls has any effect on Empty Items. It does not consider it an empty branch with the clean tree as it has an item. And null fails as they are not nulls.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/9/3/936bfde13ef1574df7e2284fd3320c449f48704d.png)

Note: This is tested in GH for V6 not V7

---

<div class="post-metadata">

**Author:** ![Michael\_Pryor](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/michael_pryor/32/489117_2.png) [@Michael\_Pryor](https://discourse.mcneel.com/u/Michael_Pryor)\
**Post date:** [June 11, 2019, 1:40pm UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/9 "2019-06-11T13:40:24Z")

</div>

Well damn. 0/2. Could have swore I did this before, guess I just don’t replace nulls / empties enough.

---

<div class="post-metadata">

**Author:** ![Adam\_M](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/adam_m/32/769331_2.png) [@Adam\_M](https://discourse.mcneel.com/u/Adam_M)\
**Post date:** [June 11, 2019, 1:49pm UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/10 "2019-06-11T13:49:59Z")

</div>

I was pretty sure I had done this too. Guess it’s just empty branches, not empties themselves.

---

<div class="post-metadata">

**Author:** ![osuire](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/osuire/32/656689_2.png) [@osuire](https://discourse.mcneel.com/u/osuire)\
**Post date:** [June 11, 2019, 2:00pm UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/11 "2019-06-11T14:00:57Z")

</div>

Hi all,

It’s funny that, when requesting for GH enhancements, I often get a whole bunch of suggestions of workarounds.  
I know them. I use them. It’s just that I think these issues deserve a proper GH tool, so basically, this kind of message is mainly targeted @DavidRutten

In this precise case, I would not care if “Null”, “Empty”, “Void”, “Nothing”, “Nada”, “Rien du tout” were treated exactly alike ; just like “Deceased”, “is no more”, “has ceased to be”, “bereft of life”, “rests in peace” and “Late” are the exact same thing : the goddamn parrot is dead for Pete’s sake !

---

<div class="post-metadata">

**Author:** ![Michael\_Pryor](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/michael_pryor/32/489117_2.png) [@Michael\_Pryor](https://discourse.mcneel.com/u/Michael_Pryor)\
**Post date:** [June 11, 2019, 2:15pm UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/12 "2019-06-11T14:15:04Z")

</div>

> It’s funny that, when requesting for GH enhancements, I often get a whole bunch of suggestions of workarounds.

Please don’t take workarounds as a fight against not having the feature. We simply try to offer what knowledge we can to aide in the meantime. Of course everyone wants these features. But if it is targeted just to David and you don’t want to open it to discussion, discourse does have a direct message feature.

---

<div class="post-metadata">

**Author:** ![osuire](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/osuire/32/656689_2.png) [@osuire](https://discourse.mcneel.com/u/osuire)\
**Post date:** [June 11, 2019, 2:17pm UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/13 "2019-06-11T14:17:54Z")

</div>

> [@Michael\_Pryor](#):
>
> Of course everyone wants these features. But if it is targeted just to David and you don’t want to open it to discussion, discourse does have a direct message feature.

Michael,  
I am mostly hoping for others to weigh in on my request, you know… like is customary in forums.

BTW, I did heavily insist in my initial post that I did not care about workarounds :

> I know about using textlenght as a hack to do this, but it is just that : a hack.

---

<div class="post-metadata">

**Author:** ![Michael\_Pryor](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/michael_pryor/32/489117_2.png) [@Michael\_Pryor](https://discourse.mcneel.com/u/Michael_Pryor)\
**Post date:** [June 11, 2019, 2:21pm UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/14 "2019-06-11T14:21:04Z")

</div>

I formally agree with the request. Better? 😀

For what it’s worth we don’t know what hacks you know except the one you mentioned. I genuinely thought those components removed empty already and you might have over looked it.

---

<div class="post-metadata">

**Author:** ![osuire](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/osuire/32/656689_2.png) [@osuire](https://discourse.mcneel.com/u/osuire)\
**Post date:** [June 11, 2019, 2:26pm UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/15 "2019-06-11T14:26:41Z")

</div>

OK Michael… but you nearly made it to my black list 😉

---

<div class="post-metadata">

**Author:** ![Michael\_Pryor](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/michael_pryor/32/489117_2.png) [@Michael\_Pryor](https://discourse.mcneel.com/u/Michael_Pryor)\
**Post date:** [June 11, 2019, 2:30pm UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/16 "2019-06-11T14:30:01Z")

</div>

> In this precise case, I would not care if “Null”, “Empty”, “Void”, “Nothing”, “Nada”

I agree there should be a case for empty, but I don’t think you can group null and empty, I think it should be different bools. Empty means there is no data (list length is 0). Null has data but it can’t be used (list length is 1) like a null mesh can still exist, you just can’t do anything to it (like baking), but you can actually fix it after the fact to be not null. For this you have the actual programming languages to blame. 😀

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/gijs/32/769882_2.png) [@Gijs](https://discourse.mcneel.com/u/Gijs)\
**Post date:** [June 11, 2019, 3:31pm UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/17 "2019-06-11T15:31:36Z")

</div>

> [@mattgaydon](#):
>
> Neither Clean tree or Replace Nulls has any effect on Empty Items. It does not consider it an empty branch with the clean tree as it has an item. And null fails as they are not nulls.

it does remove empty branches, but an empty string is not the same as empty branch, because it equals `""`

---

<div class="post-metadata">

**Author:** ![osuire](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/osuire/32/656689_2.png) [@osuire](https://discourse.mcneel.com/u/osuire)\
**Post date:** [June 12, 2019, 8:28am UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/18 "2019-06-12T08:28:36Z")

</div>

> [@Michael\_Pryor](#):
>
> Empty means there is no data (list length is 0)

OK, but then why is a branch full of “Empty” items not considered as an empty branch by “Clean tree” ?

I guess I don’t have a programmer’s mind…

 ![Empty%20Dumpty](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/5/b/5b349de6adf537f759d9c3e45577c86ffe8beb1c.jpeg)

---

<div class="post-metadata">

**Author:** ![Adam\_M](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/adam_m/32/769331_2.png) [@Adam\_M](https://discourse.mcneel.com/u/Adam_M)\
**Post date:** [June 12, 2019, 8:44am UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/19 "2019-06-12T08:44:54Z")

</div>

The list length is not zero, as [Michael Pryor](https://discourse.mcneel.com/u/Michael_Pryor) mentioned. It contains a list of empties.

The clean tree will only clean purely empty branches.

I agree though, it would be nice to have this option on the clean tree component. Clean empty items, and clean empty branches.

![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/3/8/3849aed350de7e0fd09ee76ee2168a7048271e9a.png)

---

<div class="post-metadata">

**Author:** ![osuire](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/osuire/32/656689_2.png) [@osuire](https://discourse.mcneel.com/u/osuire)\
**Post date:** [June 12, 2019, 9:02am UTC](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594/20 "2019-06-12T09:02:33Z")

</div>

This is where common sense breaks down in front of algorithmic logic.  
In my Neanderthal mind, a set full of empty items is just an empty set.

[Next page](https://discourse.mcneel.com/t/remove-empty-items-from-lists/84594.md?page=2)
