We should then be able to get the Matched content and group it so that we add it to the Required Columns to the Output Datatable using the below Expression in an Assign Activity :
mc.Select(...): Within this part of the code, the Select method is used on the Matches activity output, which is a Collection. It is employed to transform each element of the mc collection into a new structure. In this context, it’s converting each Match object in mc into an array of values.
Function(x) represents an individual Match object x within the mc collection.
OutputDT.Rows.Add(...): Within the Select function, for each Match object x, a new row is appended to the OutputDT DataTable. This row is filled with values retrieved from the subsequent expression.
Enumerable.Range(1, 4): This generates a sequence of integers starting from 1 and ending at 4 (inclusive). The sequence contains the numbers 1, 2, 3, and 4.
.Select(Function(i) x.Groups(i).ToString.Trim).ToArray: For each number in the sequence (1, 2, 3, 4), it accesses the corresponding group from the Match object x, converts it to a string, and trims any leading or trailing whitespace. The outcome is an array of strings containing values extracted from matched groups.
.CopyToDataTable: In conclusion, the resultant array of arrays (representing values from the matched groups within each Match object) is transformed into a fresh DataTable using the CopyToDataTable method. This DataTable is then populated with the extracted data.
One more question, I have to add one more column “Device name”
so the input would be like this:
Device name Glory1258
Ser.no. 200877
Inv.no. 151155
Date finished 06.09.2023. 10:27:25
Counted number 4326223
and the table would then have the column “Device name” with value Glory1258 how can I add this in the assign acitvity?
For this addition we can have the below modification :
Add the new Column with name Device Name to Build Datatable Activity, so that we have the Expected Output Datatable Schema.
Next, The Regex Expression should also be modified in the Matches Activity to also take into account the Device Name value. So the modified Expression should be the below :
I tired with 5 and 11 columns and I first added them to build datatable. The matches works fine and prints out the values correctly but when I use assign activity: mc.Select(Function(x)OutputDT.Rows.Add(Enumerable.Range(1,11).Select(Function(i)x.Groups(i).ToString.Trim).ToArray)).CopyToDatatable
the log says that outputDT has 9 rows which is okay but when I write it to excel it is empty. I can provide you my xaml if you want.
You could share the workflow, but if you could provide us with the Screenshot of Write Range Activity and the Log Message Activity before it, then it would be able to help us analyse and also help figure out the issue.