Extract Data from TXT document from a specific region

Hi,
I have managed to save a TXT file which includes a bunch of data using UiPath. Thanks to @Rahul_Unnikrishnan .
Now, We need to scroll several times to reach at bottom of txt file as it contains very long information.
Now I need to extract data inside this txt document.
Every time I run my program new documents will be created.
My data looks similar to below, for eg:
$$_BEGIN_LOG
@ rtyhihjsgtuai.ook
! 1 1 1;1 hsuia 123
! 1 1 1;1 jsnwj 456
! 1 1 1;1 qwqw 789
! 0 1 1;1 qwerw 459
! 0 1 1;1 asdfg 764

So,
$$_BEGIN_LOG is always constant
I don’t want data on Line 2. (It’s dynamic).
My data of interest is the last 3 numbers on every line. (From line 3)
And at line 6, we can see ‘0’ after ‘!’.
I want to extract the numbers until that line.
when it becomes ‘0’, data is considered invalid so no need to extract data from there.

The data I required is :slightly_smiling_face:
image

and need to send this data highlighted to an excel.
Is this can be achieved?
Many thanks in advance.

The way you’re doing this doesn’t make any sense. Why did you write data to a text file only to then try to read the data back out? Also, you don’t open text files in Notepad and scroll etc. You use the Read Text File activity to read it into a string variable and then work within the data in the variable. But you don’t need to do that because you already had the data in a variable in the first place.

Hi @John133

You have a few options here based upon your sample.

Option #1:
Take a look at this Regex Pattern.
Then take a look at this sample workflow I built. Main.xaml (6.5 KB)

Option #2 (a bit more work/advanced):
Scrape the text “$$_BEGIN_LOG” until some text AFTER the data.
Something like this sample I made. You will need to convert the result back to string
Then use this new string result with option 1 above.

@postwick there may be a business requirement to output it to a text file that @John133 did not share in his post.

Thanks @Steven_McKeering . I will try that method.
Hi @postwick , Its due to business requirements. The data can only be downloaded as txt file from an internal application.
Also I have another set of data and need to compare this data extracted from txt file with the data I already have. That’s why I want to write it to an excel.
Please advise me if there is any alternative method.

Thanks

1 Like

For the next step, I would recommend making another post to ensure you reach the biggest audience looking to help for that scenario :blush:

Then what you want to do is read the text file into a variable and then use string manipulation to get out the data you want. Split on VbCrLf, remove the first two elements, then For Each through the array and fill up a datatable by splitting/regex each line. Now you have a datatable with the above data in it and can get anything you want out of it, easily write it to Excel, etc

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