Keep original list length after path mapping

Hello,

I have 3 text files containing some data organised into columns “a” to “g” (see screenshot).
These text files have been parsed using the native “Read File” Grasshopper component and form a tree with 3 branches where each branch contains a different text file.

Problem: there is no data in columns “e” to “f” at the end of files 0 and 2. So when transposing the tree using Path Mapper, lists corresponding to columns “e”, “f”, “g” will be shorter than lists “a”, “b”, “c”, “d”.
Because file 1 does not have missing values at the end, columns “a” through “g” of file 1 have equal lengths.

I need all lists (columns “a” through “g”) of the same text file to have equal lengths.

I get the desired output when using the Flip Matrix component but this component doesn’t work for trees.

Question: is there a way to achieve this without having to manually equalise the list lengths (by adding zeros at the end for example)?

Thanks!

preserve length.gh (175.0 KB)

Hello,

Can you upload your GH file with the content of the data parameter internalized ?

Oups! Should be good now.

OK, it seems Flip Matrix is nice by adding empty tems where necessary.
I don’t think you can get away with this without adding the necessary items.
Here is a cool hack in 4 components !

preserve length.gh (171.7 KB)

2 Likes

Yay! Nice hack, thank you!

hi,
I have question
I have two lists as per the below snap
the original list with a specific structure
and after I do some analysis on the list, I want to keep the list with the same original structure,

thanks in advance

HI,

Graft to go from left to right, Trim Tree to go from right to left.

1 Like