Delete empty position

Hi,

ist there a chance to delete the empty position?

Delete%20empty%20position

You can use CleanTree component like this:


Michael.gh (16.7 KB)

1 Like

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.

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

Thank you, it works perfect

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.

That is assuming your list only made of integer types. In general, 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 :wink:

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.

1 Like

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.