Remove Nulls in List


#1

Hello,
I’m trying to remove Nulls from a list with the clean list node but I can’t figure out whats wrong here?


Help very much appreciated!

Thx Rickard


#2

Clear list from archilab
null


#3

if you want to have same sequence , try use IsEmpty node before math.sum and filter the values, in order to apply Math.sum on only the value that have a numbers


#4

Thanks for helping!
I like to try this without any packages, with that said I don’t really understand how to use the IsEmpty node. Can you please explain a little more?
I’ve also attached the DYN file

Hus A Total.dyn (7.4 KB)


#5

set lacing in List.IsEmpty to longest


#6

I still got 14 false values? :thinking:


#7

@Reklund I was able to replicate your error. Try the following


#8

Like This
empty values replaced by zeros so that the sum will not effected with them


#9

Hello guys!
Both ways work perfectly! Thank you so much!

khuzaaimah.ElecEng: This makes sense to me, I understand this :slight_smile:

Salvatoreredragotta: It’s working perfectly, but I can’t understand why, care to explain? If not, thank you again. I appreciate the help!

  • Rickard

#10

@Reklund
Your list has empty strings at the end.

image

The List.Clean node doesn’t remove those. So you’ll have to replace empty strings with null, using conditional (similar to IF in revit formula) in a code block node:

item!="" ? item : null

!= mean does not equal.
"" and empty string


#11

Why are you doing a check “if area is empty” rather than cleaning up your list?

Would it be more clear to just do that (removing nulls from list?) (in my case index 51).

Python script would be:

input = IN[0]
OUT = filter(None, input)

#12

I agree with @3Pinter clean up before instead of at the end. Here is another solution