Spliting the multiple line in text file and pasting the values in excel

Hi all
My scenario here is to get the text after 1 1 1.There are 3 to 4 places where we have 1 1 1. Where it is there we have to get the values after this. I have attached my case text file for reference. My result should be like
-3961.40 -100.63 319.15
-4011.49 -119.40 292.23
These are the values after 1 1 1.
Help me extract this values and copy it in an excel and split the 3 values in 3 columns.
Please provide any xaml file for solution.
Thanks in advance


TEST.zip (677 Bytes)

This forum isn’t (or shouldn’t be) a code writing service, but help you in coming up with a solution on your own. Here’s one possible approach using Regular Expressions: this example matches all your requested rows.

Here’s how you can use Regular Expressions in UiPath:

Hi Newton,

Please follow these steps
Step1: Read Text file activity output will be in type String .
Step 2 Use matches activity give input as string what you extracted from note pad Use this regex((?<=[1]\s*[1]\s*[1]\s*).+)
Step 3:matches gives array of IEnumerable matches
Step 4:Split this by new line then again split it by space and store it in variable
Step 5:Use build data table and add 3 columns
Step 6:Use add data row activity to add the extracted value from regex
Step 7:Use write range activity to write data into excel.

Thanks,
Gouda

1 Like

Hi @Newton_Rich_SV

In case you are not sure how you should start on this, I have simplified your problem for you. There are many approaches that you can do for this. One option is to use regular expressions just like the other two guys above have mentioned. The other option is to directly use Generate Data Table activity to convert your string to a datatable where you can do filtering and stuff to get your dataset prepared.

I have a small xaml file that uses this Generate Data Table activity. I do not have the entire solution for you, but this simplifies the entire thing. So you just need to check the output of this using the debug mode, and figure out how to get it onto an excel file

SplitDataInTextAndAddToExcel.xaml (5.2 KB)

2 Likes

Hi Newton,

Attached Xaml file by doing slit modification as suggested by @Lahiru.FernandoSplitDataInTextAndAddToExcel.xaml (6.7 KB)

Thanks

1 Like

Hi guys
Thanks for your reply.
I have used regex for spitting the text after
(1 1 1). Text has been splitted throughout the text but I am getting blank lines inbetween. Please provide some solution for removing the lines and writing the values in excel.
I have attached my text file and xaml file for reference.
Thanks
HP - Copy.zip (6.9 KB)

Hi @Newton_Rich_SV,

Did you refer the above code?
it gives solution for your query…

Thanks,

Hi @Gouda_6
I tried to apply those codes. But I was getting some error. Thats why I used regular expressions. Help with the solution.
Thanks

@Newton_Rich_SV

To get all lines which starting with 1 1 1

Output of this expression is matchcollection variable

System.Text.Regualrexpression.Matches(yourstring," (+1){3}(.+)")

Use above equation for each and use match as variable type.
(mt is variable system.text.regularexpression.match type)
Foreach mt in System.Text.Regualrexpression.Matches(yourstring," (+1){3}(.+)")

And find numbers which you want

Use following expression to get number values -?\d+.\d+