Group lines depending on a condition

Hello, can anyone help me with this problem?

I have a scenario where I read a text file with several lines. So far good. Then I process the lines and depending on a condition that comes in some lines, always the same condition, I must separate these lines into groups and then with each group create an XML with certain data.

Example:

asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioBBBpjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioBBBpjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioBBBpjklñ5555urqioepjfkalfjkalñ

Assuming that the condition is that the text ‘BBB’ is informed, I must separate this file into 3 groups, the first group will contain the first 3 lines, the second group will contain the next 4 lines and the third group the remaining ones. There could be many more lines to come.

Thanks in advance

@JoseLopez :raised_hands:

Hi there! I’m an AI that is still learning, so I’m not able to provide a solution to your problem. However, I can help you by analyzing your message for typical information that might be missing for our community members to help. Can you provide more details about the condition that you mentioned? What is the text ‘BBB’ referring to? What kind of XML are you trying to create? Any additional information would be helpful.

Please take a camera-viewfinder-duotone screenshot of your scenario along with the relevant module configurations and share-all-duotoneshare the images here so that the community can help.

All of this helps us to get a deeper understanding of the challenge you face. :make:

In the image you can see the processed lines and the condition that must be met to separate them into groups is that the letter -U- appears in a certain position. You can see how the letter -M- first appears in that position until you reach bundle 6 where a -U- appears. So I want to group these 6 lines together to form an XML with some data from those lines. The XML is not important here.
Then, the 7th line should be part of another new group, together with the 8, 9,… line until another -U- is found, and so on.

1 Like

I recorded a short screen-sharing video to explain the resolution.

Watch here: Loom | Free Screen & Video Recording Software | Loom

1 Like

Hi manish_mandot, thanks for your answer but it is not what I need.
Considering the example, the groups should be as follows:

Group 1:
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioBBBpjklñ5555urqioepjfkalfjkalñ

Group 2:
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioBBBpjklñ5555urqioepjfkalfjkalñ

Group 3:
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioAAApjklñ5555urqioepjfkalfjkalñ
asdfadg1234jklñuioBBBpjklñ5555urqioepjfkalfjkalñ

that is, when it finds the character of the ‘BBB’ condition, a group must be created with the previous lines and the ‘BBB’ line itself.
The next group will start on the line after the first ‘BBB’ (line4 in the example) and so on.