Data Extraction from text file


I need to Extract data from text file and write it into excel file. I’m attaching input text file and in that file we have few lines which start with L1*<<,L2*<<,L3*<<,… Ln*.

After the “L” line we have a 6 character length line which is PNR line. Immediately after the PNR line, passenger names start. Each passenger is given a number as 1.1, 2.1, 3.1, 4.1, 5.I etc.

the number of occurrences of 1.1,2.1,3.1 is not static it varies. Hence I need extract it in a dynamic way.

Any leads in helping in extraction is much appreciated.

TestData.txt (8.8 KB)

there are different options like regex, string processing.

Have a start like:

Splitting the blocks with regex:

then you can process each block individually


For the passengers again extract the block and the info:


finally we can split on line break, trim & clean and parse more the passengers lines

Also have a look here:
[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum

1 Like

Hi @ppr thanks for your reply.

Your regex code to extract names is grouping entire 4 to 5 lines of data. I only need to extract what ever the lines which has 1.1,2.1,3.1,…etc and I dont need the data of lines starting with EY to getting in the group.

once the block is extracted then for postprocessing we can do the filtering - e.g. evaluating the start part

  • split the lines by
    arrPassengers = strPassengerBlock.Split({Environment.NewLine}, StringSplitOptions.None)
  • then filter arrPassengers

We would also recommend to reformulate/recheck the filter criterias. Currently we would understand that following is requested:
Line starts with digit-dot-digit - regex: \d\.\d

Could you please help me more in detail. I’m looping all the matches in for each loop and I have set the type argument to “system.text.regularexpressions.regex.match”. and When I use the split expression which was provided by you in the same for each loop to split the data I encounter error which says split is not a member of “system.text.regularexpressions.regex.match”.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.