List matching - how to keep using the same data order in two lists

Hello everyone,
I’ve used the node Element.HostElement-ArchiLab from ArchiLab package, to filter out the curtain panels hosts.
The issue now is that the given results are ignoring the previous list’s data order, so it is kind of difficult to understand which list related to which list…

So as you can see, the first list has 4908 sub-lists, but the second one has only 771 lists.

How could I keep the same data order from the first list and applies to the second one?

Thanks in advance

Hello, could you enlarge your screenshot? This one is not enough to understand how you get this list of empty items…

Node from Archilab clearly skips empty lists, so maybe remove empty/null before this node. Otherwise show paste python code from hostElement node

Here is the whole process, basically the target was to group curtain panels by their associated rooms from linked files.

Thanks for your reply!

I’d like to keep the same sublists number without flatting, till the export later as an Excel file.
Here is the code from hostElement node:

#Copyright© 2015, Konrad K Sobon


import clr
import sys

pyt_path = r’C:\Program Files (x86)\IronPython 2.7\Lib’

Import Element wrapper extension methods

import Revit

Import DocumentManager and TransactionManager

import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

Import RevitAPI

import Autodesk
from Autodesk.Revit.DB import *

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

if isinstance(IN[0], list):
elements = []
for i in IN[0]:
elements = IN[0]

def GetHostElement(element):
doc = DocumentManager.Instance.CurrentDBDocument
host = element.Host
return host
hostIds = []
for i in element.GetHostIds():
return hostIds
return None

def ProcessList(_func, _list):
return map( lambda x: ProcessList(_func, x) if type(x) == list else _func(x), _list )

errorReport = None
if isinstance(elements, list):
output = ProcessList(GetHostElement, elements)
output = GetHostElements(elements)

if error accurs anywhere in the process catch it

import traceback
errorReport = traceback.format_exc()

#Assign your output to the OUT variable
if errorReport == None:
OUT = output
OUT = errorReport