# Delete empty position

**URL:** <https://discourse.mcneel.com/t/delete-empty-position/78436>\
**Category:** Grasshopper\
**Created:** [February 7, 2019, 10:23am UTC](https://discourse.mcneel.com/t/delete-empty-position/78436 "2019-02-07T10:23:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael.haertlein](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/michael.haertlein/32/660626_2.png) [@michael.haertlein](https://discourse.mcneel.com/u/michael.haertlein)\
**Post date:** [February 7, 2019, 10:23am UTC](https://discourse.mcneel.com/t/delete-empty-position/78436/1 "2019-02-07T10:23:19Z")

</div>

Hi,

ist there a chance to delete the empty position?

![Delete%20empty%20position](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/d/0/d06637a6d4048d67a10cc9b517892f5d85cf4dea.jpeg)

---

<div class="post-metadata">

**Author:** ![Mahdiyar](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/mahdiyar/32/472862_2.png) [@Mahdiyar](https://discourse.mcneel.com/u/Mahdiyar)\
**Post date:** [February 7, 2019, 10:34am UTC](https://discourse.mcneel.com/t/delete-empty-position/78436/2 "2019-02-07T10:34:22Z")

</div>

You can use `CleanTree` component like this:

 ![Michael](https://global.discourse-cdn.com/mcneel/original/3X/f/0/f0cea6095cc18de175e858d9cbe8a202312ba31f.png)  
[Michael.gh](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/3/6/368ef4015df3b2626dac2faa77b61f0676572b8c.gh) (16.7 KB)

---

<div class="post-metadata">

**Author:** ![HaLo](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/halo/32/216615_2.png) [@HaLo](https://discourse.mcneel.com/u/HaLo)\
**Post date:** [February 7, 2019, 10:36am UTC](https://discourse.mcneel.com/t/delete-empty-position/78436/3 "2019-02-07T10:36:01Z")

</div>

There shouldn’t be any “empty” positions in a list.

My guess is, your numbers actually are strings, because those can have no content and still be valid.

You may route those numbers trough a number parameter to make sure of the type. Empty strings should translate to NULL. You can then clean up the NULL items.

---

<div class="post-metadata">

**Author:** ![DavidLeon](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidleon/32/256448_2.png) [@DavidLeon](https://discourse.mcneel.com/u/DavidLeon)\
**Post date:** [February 7, 2019, 10:42am UTC](https://discourse.mcneel.com/t/delete-empty-position/78436/4 "2019-02-07T10:42:29Z")

</div>

In Michael’s example, seems that the item is a whitespace string, not a _null_ nor an _empty_ item. If they are strings with whitespace, you can remove it with _TextTrim_ component, then use _CleanTree_ to remove the _empty_ item, like mentioned above

---

<div class="post-metadata">

**Author:** ![michael.haertlein](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/michael.haertlein/32/660626_2.png) [@michael.haertlein](https://discourse.mcneel.com/u/michael.haertlein)\
**Post date:** [February 7, 2019, 10:56am UTC](https://discourse.mcneel.com/t/delete-empty-position/78436/5 "2019-02-07T10:56:44Z")

</div>

Thank you, it works perfect

---

<div class="post-metadata">

**Author:** ![Mahdiyar](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/mahdiyar/32/472862_2.png) [@Mahdiyar](https://discourse.mcneel.com/u/Mahdiyar)\
**Post date:** [February 7, 2019, 11:07am UTC](https://discourse.mcneel.com/t/delete-empty-position/78436/6 "2019-02-07T11:07:35Z")

</div>

In this case, the most promising method is to connecting the data to a `number parameter` and then cleaning the **null** , **invalid** and **empty** items.

 ![Michael](https://global.discourse-cdn.com/mcneel/original/3X/4/4/44d3be8be1c582c50818dd58b92b194d505a2784.png)

---

<div class="post-metadata">

**Author:** ![DavidLeon](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidleon/32/256448_2.png) [@DavidLeon](https://discourse.mcneel.com/u/DavidLeon)\
**Post date:** [February 7, 2019, 11:16am UTC](https://discourse.mcneel.com/t/delete-empty-position/78436/7 "2019-02-07T11:16:05Z")

</div>

That is assuming your list only made of integer types. In general, its not a good thing to have red components.

---

<div class="post-metadata">

**Author:** ![HaLo](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/halo/32/216615_2.png) [@HaLo](https://discourse.mcneel.com/u/HaLo)\
**Post date:** [February 7, 2019, 11:42am UTC](https://discourse.mcneel.com/t/delete-empty-position/78436/8 "2019-02-07T11:42:13Z")

</div>

> [@DavidLeon](#):
>
> its not a good thing to have red components.

Red means a failed operation. You can use that to determine the validity of your input.  
Or you can just assume your input is always valid. Then you wouldn’t have Michaels problem in the first place 😉

I know it’s kind of dirty, but I use typecasts like that pretty often. Sometimes operations have empty or null input in some branches so the entire component will turn red. Als long as you know why and what’s happening, even red components shouldn’t bother you.

---

<div class="post-metadata">

**Author:** ![e.tamrabadi](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/e.tamrabadi/32/502462_2.png) [@e.tamrabadi](https://discourse.mcneel.com/u/e.tamrabadi)\
**Post date:** [September 29, 2023, 9:20am UTC](https://discourse.mcneel.com/t/delete-empty-position/78436/9 "2023-09-29T09:20:33Z")

</div>

This is a problem that is not yet solved with the clean component.  
I think the real problem is that in one of the updates, a string empty item is not an actual empty item.  
If you’re dealing with string-type data, connecting the node to a number parameter would be problematic because it turns all the string-type data into null. In this case, I offer this solution to use the text length component that shows the length of the empty string item as 0.  
In this case, I wanted to maintain the branches that have some not-empty items inside but you can alter the process to remove empty items as well.

 ![Empty items](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/2/e/2/2e2dc7654b12948b6f6e1ca11a54213b26b6acbf.jpeg)
