I’m trying to create a Datatable dynamically, iterating another datatable.
I have a Datatable1, which has columns a,b,c,d,e,f.
I have another datatable2, which is just instantiated as a variable but with zero columns in it.
I’m iterating this Datatable1 using it columns, like
for(eachcolumn in datatable1.columns){
having “add data column” item inside to which I’m passing datatable2 and column, so the column of datatable1 is added to datatable2, and so on for all the columns. so I don’t need to create the columns beforehand but added as per some conditions and only those columns needed for datatable2 of datatable1.
}
Throwing this error, Column ‘a’ already belongs to another DataTable.
The error is since you are directly adding the datacoumn object to a new datatable2.
What you should do is use the invoke method activity and invoke datatable2.columns.Add activity and pass eachColumn.ColumnName and eachColumn.Datatype as parameters to it.
it worked but when I write this dt2 to xls, I see an empty row being added between Header row and the first row.
When I print the no of rows of dt1, it says right count figure but why is this being started with a row gap rather starting immediately after the header row.
Just attaching the workflow with the folders/package structure, so its easy to figure out just by running with minimal changes in the json config file for “filepath” attribute in the file,
It’s all resolved guys.! there seems to be mistakenly an empty row added to the new datatable(manual mistake) and so there is an empty row gap in the csv/xls file generated after the header.