2.txt (9.3 KB)
I have data in text file. Now I want to filter my data to below format. how can I do it can anyone help me please.
Hi,
Can you try the following sample?
mc = System.Text.RegularExpressions.Regex.Matches(strData,"(?<=^|\n)Command\s+:(?<Command>.*)\r?\nCyc\s+:(?<Cyc>.*)\r?\nScheduled\s+:(?<Scheduled>.*)\r?\nRun\s+:(?<Run>.*)\r?\nKill\s+:(?<Kill>.*)\r?\nMatch\s+:(?<Match>.*)\r?\nSTA\s+:(?<STA>.*)\r?\nSlave\s+:(?<Slave>.*)\r?\nType\s+:(?<Type>.*)\r?\nComment\s+:(?<Comment>.*)\r?\nDesc\s+:(?<Desc>.*)\r?\n")
mc = System.Text.RegularExpressions.Regex.Matches(strData,"(?<=^|\n)c12_command[\s\S]+?:(?<c12_command>.*)\r?\nc12_activeind[\s\S]+?:(?<c12_activeind>.*)\r?\nc12_day[\s\S]+?:(?<c12_day>.*)\r?\nc12_culltime[\s\S]+?:(?<c12_culltime>.*)")
Sample
Sample20240226-3 (2).zip (10.7 KB)
Regards,
Hi,
Here we are getting only columns in excel file but I want respective column data. Can you please tell me.
Hi,
The above outputs text data as datatable as the following.
If you need to filter these rows, can you share specific condition?
In general, we can achieve it using FilterDataTable activity, LINQ or DataTable.Select method.
Regards,
I am getting the output as accepted but in that text file at last we have one more format i.e slaves and Last recorded activity. as shown in below image.

So, what regex can I use can you please tell me.
Hi,
How about the following sample?
mc = System.Text.RegularExpressions.Regex.Matches(strData,"(?<=^|\n)SLAVES[\s\S]+:(?<SLAVES>.*)\r?\nLast recorded activity\s+:(?<Lastrecordedactivity>.*)")
Sample
Sample20240226-3 (3).zip (11.4 KB)
(Please check result3.xlsx)
Regards,
Here, I am not getting Last recorded activity data.
Hi,
Can you elaborate?
In my environment, the above sample returns excel sheet as the following image.
Regards,
Here In my excel sheet I am getting only SLAVES data.
Hi,
Did you use text file included the above sample zip or any other input file?
Regards,
The same text file i have used. Can you share your workflow once.
Sure. Here you are.
Edit: Sorry, but the following is the latest.
Sample20240226-3 (3).zip (11.4 KB)
I will check on it and thanks for your help really it’s very helpful for me. Thankyou So much.
Hi Yoichi,
In regular expression I am getting an error like groups and select is not a member what can I do to resolve this error.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.