Hi @vrdabberu,
I tried the invoke code method but I am currently facing this error regarding the data type:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.InvalidCastException: Unable to cast object of type ‘System.Double’ to type ‘System.String’. at System.Data.DataRowExtensions.UnboxT1.NonNullableField(Object value) at UiPathCodeRunner_6bf1a3c0dc0242a9abdc28ac18bb389e._Closure$__._Lambda$__0-0(DataRow row) at System.Linq.Enumerable.SelectEnumerableIterator
2.MoveNext()
at System.Collections.Generic.List1..ctor(IEnumerable
1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at UiPathCodeRunner_6bf1a3c0dc0242a9abdc28ac18bb389e.Run(DataTable dt, DataTable& newDT) at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span
1 copyOfArgs, BindingFlags invokeAttr)
— End of inner exception stack trace —
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span1 copyOfArgs, BindingFlags invokeAttr) at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args) at UiPath.Activities.System.Utilities.InvokeCode.CompilerRunner.Run(Object[] args) at UiPath.Activities.System.Utilities.InvokeCode.NetCodeInvoker.Run(String userCode, List
1 inArgs, IEnumerable`1 imps, Object args)
at UiPath.Core.Activities.InvokeCode.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
Below is the data from excel file that I read and save as datatable. I want to read from row 10 as the header is unique to get the any data below the column :

I try changing the argument as below (This is my first time using invoke code method actually). I hope I am doing it right.

Below is the output table header (csv file) that I need to write the final output. Which I have match as per your example.
Invoke code I have changed:
’ Initialize the new DataTable
newDt = New DataTable()
newDt.Columns.Add(“Eng_Model”, GetType(String))
newDt.Columns.Add(“NOx”, GetType(String))
newDt.Columns.Add(“Eng_SFOC”, GetType(String))
’ Add the first set of columns to the new DataTable
Dim transformedRows1 = dt.AsEnumerable().Select(Function(row) New With {
.Eng_Model = row.Field(Of String)(“ME1.TYPE”),
.NOx = row.Field(Of String)(“ME1.NOX”),
.Eng_SFOC = row.Field(Of String)(“ME1.SFOC”)
}).ToList()
’ Add the second set of columns to the new DataTable
Dim transformedRows2 = dt.AsEnumerable().Select(Function(row) New With {
.Eng_Model = row.Field(Of String)(“ME2.TYPE”),
.NOx = row.Field(Of String)(“ME2.NOX”),
.Eng_SFOC = row.Field(Of String)(“ME2.SFOC”)
}).ToList()
’ Add the transformed rows to the new DataTable
For Each row In transformedRows1
newDt.Rows.Add(row.Eng_Model, row.NOx, row.Eng_SFOC)
Next
For Each row In transformedRows2
newDt.Rows.Add(row.Eng_Model, row.NOx, row.Eng_SFOC)
Next
The data has decimal point.
Need your advise on this, thank you.