How to replace all null with multiple values

hello, I have two lists that have corresponding null values that I need to splice together, but how do I replace multiple null values with the multiple (different values) for each null value. I want to have one full list, with only the values of these two lists. but need to retain their relative index positions no matter what. meaning if the nulls are in different indicies the next time i run it. Thanks!

Maybe something along the lines of this?

2 Likes

@mix See if this serves your purpose…

replaceNull.dyn (10.9 KB)

3 Likes

Hi erfajo,

I havent upgraded to orchid yet because I have so many scripts that require your DANedu nodes that it would be a pain to have to go back and try to fix them all. Because to get Orchid you have to remove the DANedu package. If your package had all the same nodes, left the same way then I might do it. But its working and I dont want to mess with it at this point. Plus, if I remember correctly, to get Orchid I had to update Dynamo itself to 2.0 and that in-and-of-itself messes even more stuff up. So unless you know of specific problems with your DANedu nodes that you would like to point out, then please forgive me for not updating at this time.

Hi @Dimitar_Venkov
Looks like i must be doing something wrong with your solution because it does not work for me. Please see below.

Thanks @Vikram_Subbaiah that is a very simple and eligant solution. I should have thought of that! Thanks!

1 Like

Hi Vikram ji,

If you see in my case I want to replace nulls in list(1) by the items in the list(2), without messing the indexes. At 41th position, the item should have been “CW_drainageSystems_pipe” but is actually “gully trap”.

Please assist.
Regards,
ap

Done using python.
Thanks anyway!

atharvapurohit

You could also try this.
(This could be done with nodes too).

//Null Indices
in1 = List.AllIndicesOf(DSCore.Object.IsNull(ls1),true);

//Other Indices
in2 = List.SetDifference(0..List.Count(ls1)-1,in1);

//Flattened list of indices in sequence
ls3 = List.Flatten([List.Clean(ls1,false),ls2],-1);

//Flattened list of non null and replacements in sequence
in3 = List.Flatten([in2,in1],-1);

//Sort flattened list to restore order
ls4 = List.SortByKey(ls3,in3)["sortedList"];
3 Likes

Thank you @Vikram_Subbaiah ji, but is this solution a bit complicated?
I might be wrong, though.

br,
atharvap