Hi All,
So in my data tree there is empty and null branch. How can I script in a way that test for null/ empty, if true grab the nearest data above them?
Hi All,
So in my data tree there is empty and null branch. How can I script in a way that test for null/ empty, if true grab the nearest data above them?
You can use the NullRep (“Replace Nulls”) component to substitute null values with other data.
Usually the clean tree component works well.
I had a problem involving this the other day where I had to measure the length of the text and input that into If(x>0,True,False) in an expression block, then cull the list based on that pattern.
Or even simplier:
for(int i = 1; i < x.Count; i++) { if(x[i] == "" || x[i] == null){ x[i] = x[i-1]; } } A = x;
which is exactly what @Baris done without scripting.
That is mostly correct. just be aware that 1st item is problematic because you’re telling it to take one before Python is smart so it will take last item instead (which btw could be empty too).
That’s why I excluded 1st element from cycle. Even better would be to write special test for 1st item and decide what to do with it in case it is empty. I decided to replace it with first not empty/null element after it.