mr_Fajar_28
(Muhamad Rizky Fajar)
1
Hello
I have text and i want to split with code and create into data tables.
For example :
"CodeNumber : 20 NumberPage : 1
No Date IdName Status
1 11/04/2022 01_abc Active
2 11/04/2022 02_def Acttive
3 12/04/2022 01_abc Inactive
4 12/04/2022 02_def Active
CodeNumber : 25 NumberPage : 1
No Date IdName Status
1 11/04/2022 03_ghi Active
2 11/04/2022 04_jkl Acttive
3 12/04/2022 03_ghi Inactive
4 12/04/2022 04_jkl Active"
I want to separate data with certain code numbers and make it into a data table. Any Idea how to solve it, can someone help me?
1 Like
Hi
Welcome to uipath forum
We can split this with Regex split and then convert that split text into datatable using generate datatable activity
Hope the below steps would help you resolve this
- Use a Assign activity like this
Arr_input = System.Text.RegularExpressions.Regex.Split(strinput.ToString.Trim, “CodeNumber: (\d){1,2} NumberPage: (\d){1,2}”)
Where arr_input is a variable of type array of string
-
Now use a FOR EACH activity and pass the above array variable as input and change the type argument as string
-
Inside the loop use a GENERATE DATATABLW activity and pass input as item.ToString and get the output as dt
-
Then search as workbook in activity panel and drag the Write range activity next to the above generate datatable activity inside the loop
-
Where mention the input as dt and enable add headers and mention sheet name as “Sheet”+Array.IndexOf(arr_input, item.ToString).ToString
-
Finally inside the loop use a clear datatable activity and pass input as dt
Cheers @mr_Fajar_28
1 Like
Yoichi
(Yoichi)
3
Hi,
Another approach using Matches method :
mc = System.Text.RegularExpressions.Regex.Matches(strData,"CodeNumber : (?<CodeNumber>\d+) NumberPage : (?<PageNumber>\d+)\r?\n\r?\n(?<TABLE>[\s\S]+?)(?=\r?\n\r?\n|\s*$)")
Sample20220413-3.zip (3.0 KB)
Regards,
1 Like
system
(system)
Closed
5
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.