Mat,
Welcome to the forum.
We would love to help you further but I have to admit that I didn’t get what you want to do actually. Could you elaborate a little more detailed please?
Regardless of that: When you post code or sample data or console output please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Thanks in advance