Split datarow based on specific string character

Hi team could you help me with this topic. I have a datatable (input, see image below), and I require to get the output(see image below), i am trying to split the datatable based on space,enter or any other delimiter to get that result

I’m using this code in a invoke code activity but it doesn’t retrieve the expected output

Dim dtResult As DataTable = dtOriginal.Clone()

For Each row As DataRow In dtOriginal.Rows

Dim values As String() = row.ItemArray.Select(Function(x) x.ToString().Split(" "c)).SelectMany(Function(x) x).ToArray()

For i As Integer = 0 To values.Length - 1 Step dtOriginal.Columns.Count



How about the following?

dtResult = dt.AsEnumerable.SelectMany(Function(r) Enumerable.Range(0,r(0).ToString.Split(" "c).Count).Select(Function(i) dt.Clone.LoadDataRow(dt.Columns.Cast(Of DataColumn).Select(Function(dc) r(dc).ToString.Split(" "c)(i)).ToArray,False))).CopyToDataTable()

Sample20240321-1.zip (9.1 KB)

Note: this sample assumes all the cell in same row has same number of items.


1 Like

Thanks very much @Yoichi , that is exactly what I require. That answer is brilliant

1 Like

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