Custom Populating Revit Schedule (MEP Fabrication Pipework: Connector's Information)

Hello all, I am trying to create a Revit Schedule using Dynamo for a project that involves MEP Fabrication Services like pipework etc. I was able to query most of the information but I am stuck at populating ‘End Prep’ information. I used the following script to query and populate end prep information. Initially, I got the output as ‘Null’ so I thought there must be a problem with the script but after some troubleshooting I found out that there are certain services (elements) within the project whose ‘end prep’ information is missing in the model itself. So, if I include them in the script I would get the whole output as null.

So, I identified and excluded the index numbers of all such elements from the script and ran the script and got the output.

However, now the issue if I exclude the 21st element (since it gives the output null) and run the script, the order in which the information is supposed to get filled in the revit schedule is affected. I mean, the information of 22nd element gets filled on 21st row in the revit schedule. Is there any way I can avoid this? Can I run the script and still keep the 21st row blank?
Kindly help. Thank You.