Hello I need merge every second line from string with the previous line. I.e my string looks like this
aa bb SRC 8
aabbccc xxxxx.
ab bc SRC 8
aaabb xxx.
ba bbc $AT 8
ccbbaa xxxxxx.
And I need it to change to this
aa bb SRC 8 aabbccc xxxxx.
ab bc SRC 8 aaabb xxx.
ba bbc $AT 8 ccbbaa xxxxxx.
and then put it into datatable.
Thanks for help
Merge every second line with the previous line using LINQ query:
Use the Assign activity with a LINQ query to merge every second line with the previous line:
vbnetCopy code
mergedLinesArray = inputLinesArray.Select(Function(line, index) If(index Mod 2 = 0 AndAlso index + 1 < inputLinesArray.Length, line & " " & inputLinesArray(index + 1), line)).Where(Function(x) x IsNot Nothing).ToArray()
Create a DataTable and add the merged lines to it:
Use the Build Data Table activity to create a DataTable with the desired columns.
Use a For Each activity to iterate through the mergedLinesArray and add each merged line as a row to the DataTable using the Add Data Row activity.
Don’t know why but I can’t split string into array. The whole table is one array. I have a lot of spaces at the end of each line, maybe that is the reason?