List control, Combine two lists with lots of Nulls but some information

Hi, I have two lists of 23.

The first list contains the information I need in the first 4 of the list as shown with the rest as Nulls.

The second List contains the information I need but from 17-22 in the list.

I would like a resulting list of 23 with the information i need in one list of 23.

Doesy anybody know how I might do this?

Try this way:

Thanks for the reply, the list format i’m looking for is slightly different. Hopefully the below list explains better.

Try to replace “Null” with an empty string and then combine list:

List.Create

List.Transpose

List.Clean

Thanks Jacob, Could not get that to work. Jahannes suggestion seemed to get me on the track.

I used a list.replacenull with a space then ran the list combine. as shown.

Beautiful. Thanks for the help guys

1 Like

My suggestion is not that elegant, and keep an eye on empty spaces :wink:

Here is an example of what @jacob.small said. If it did not work, it might be because you forgot to use False for preserveIndices input on List.Clean:

Honestly, IMO it should be the best method, it avoids a lot of unnecessary steps that could cause problems.

Here is an if statement alternative as well:

3 Likes

That works great if you are creating a list with 0 nulls remaining. How ever I am looking for list structure similar to the excel sheet I posted above.

The if statement should still work then.
twolistnulls

Just trying to give an option that doesn’t rely on your inputs being strings and can handle other types.

1 Like

I do apologise I thought both of those scripts did the same thing without trying. Very Grateful for the help that worked beautifully!

Out of interest do you know of some kind of code block cheat sheet for expressions, this solution has perfectly framed the elegance of using code blocks more often.

image

1 Like

out of interest if i had 3 or 4 lists what would the code block look lilke?

1 Like

Code blocks are written in design script, so you would need to look up information on that. I know there should be a few posts on where to find design script guides and information on the forum, just search “design script”.

Here is one pdf I use: https://dynamobim.org/wp-content/links/DesignScriptGuide.pdf

and another intro guide: http://designscript.io/DesignScript_user_manual_0.1.pdf
Somewhere in this one it describes in-line conditionals which is what I used.

I don’t have a cheat sheet for design script, though if there was one it would be incredibly handy.

As for if you had more lists, you would need to extend the if statement into an else if by adding more if statements in the false block (would be easier if instead of == you use != or not equal to):

w != null? w: (x != null?: x: (y != null? y: z));
Parenthesis might not be necessary but help to read.

Another good design script resource: GitHub - Amoursol/dynamoDesignScript: DesignScript workflows for Dynamo

1 Like

more cheat sheets can be found here