Make all List Equal Length

Hi,

A question came up today on how to write data to excel that have un-equal nested lists.
Sample list content:


And trying to map it to:

This will allow the List.Transpose and Excel.WriteToFile to work correctly.
I have come up with the attached graph but it’s very rigid and is the wrong approach and it also add’s unwanted data.List to Excel.dyn (16.7 KB)

Suggestions?

If you transpose the list from the first picture the result should be the 2nd piucture

Sorry you’ll also need to replace the null values

1 Like

I need the nested lists to be the same size. ie. 7 items.

My graph sample did the following:

  • Found the longest length nested list
  • looped through each nested list and add additional items to the list to get the list count to 7 items.

Sorry I must not be understanding. I thought you wanted a way to get what you had in the first picture to look like the 2nd picture but without you have to add “” to even up the lengths of the list

The below outputs are identical from the 2 different lists you’ve given as inputs.

What you replace the null with can be anything

My second image was just showing what I wanted the out in the Watch node to look like. I just don’t know the best way to get random lists to include the null values based on the maximum nested list length.

So,
The maximum nested length = 7
So I need to make sure all my nested lists length = 7 items long.

Result should be 3 lists of 7 items like shown in the second image.

??

1 Like

1 Like

Thanks Jimmy that worked when I added the second List.Transpose.

I don’t fully understand how “by Replace Nulls” is actually working. How does it know where to add the Nulls to Replace?

The first transpose will add null values if it can’t find a value. If you don’t mind the values being nulls you can just transpose then transpose again without removing the nulls

Thanks Jimmy.
Yea I needed to scroll down my Watch node on the First List.Transpose to see the input null values. This is what through me off.

haha no worries mate