Combining nested lists

hi, does anyone know how to combine the lists at level 3 that could be multiple variables to one? All the ohter lists at level 2 are the same amount with different amounts at level 1. Just need them into the level 3 nested lists. I’m taking the same sheets from multiple buildings as typical details and need them all referenced on the one detail sheet. not 3 or whatever number of buildings if that makes sense. Merging or joining the level 3 lists to one level 3 list

you can lacing the flatten @vanman

1 Like

As @Draxl_Andreas List.Flatten works great.

If you want to “flatten” from the other side, i.e. get 1 to 9 in a single list use List.Normalize.

1 Like

I need the level 3s whatever it is to merge into one whatever the level 2s are cause theyll always be the same but different lengths at level 1`

plus the level 3s will change length depending on how many buildings

but all the different lengths at level 2 and 1 will merge into the 3…

Flatten @L3?

@vanman @Nick_Boyts

i had also the “fantasy” of a dynamic flatten via python f.e.

flatten is just looping througth a list

OUT = []
for i in IN[0]:
     for x in i:
        for z in x:
               OUT.append(z)
OUT = []
for i in IN[0]:
     for x in i:
        for z in x:
            #do it until a certain Level
                 OUT.append(z)
                 break
1 Like

When would you use something like this over the node? Don’t list levels accomplish the same thing?

how can i catch my correct list? @Nick_Boyts
i hope i do not change the topic :slight_smile: … i can create one

I think I understand what you’re describing now but I’m not sure the python code would fix it. Since it would keep list levels in tact, I think you’d still end up with the same lists as the node after flattening.

The issue is that once you combine lists, their list levels remap to the new list. So L2 for each of the individual list in your example represent the same level. But once they get combined into a single list that is no longer the case. So the solution may just be to handle the lists individually at first.

@vanman, can you show us the full list structure for your list and an example of exactly how you want that list structured in the end?

2 Likes

Thanks for your help! I’m sure it’s like a join or combine thing but I’m not sure how to do it when it’s not separate lists and it’s the same list. Did an example below. Hopefully it makes sense :sweat_smile:

Transpose, Flatten and Clean


transpose.dyn (11.4 KB)

3 Likes

Thank you for all your help!!!