Is there any efficient way to set column names(with build datatable activity)

Since there are hundreds of column names, is there any other efficient way to set column names when using the build data table activity, rather than manually entering each column name?

image

Hi @111962

You can try with below expression

(from P in DT1.Columns.Cast(of DataColumn)Select P.ColumnName).ToArray

DT1 → Your datatable
Regards
Gokul

1 Like

create a list / array of column names - colNameSet
create an empty datatable with myDT = new DataTable()
pass the colNameSet to a for each acitvity

  • create within the for each with the help of add DataColumn Activity the datacolumn and add it to myDt
1 Like

Hi,

Can you try to use GenerateDataTable activity with UseColumnHeader option?

If you have comma separated string data, the following will work.

If you have string array, the following will work.

Note: The above is assumed there is no special character in column name.

Regards,

1 Like

How is this datatable being populated? Unless you’re using Add Datarow, you don’t need to do Build Data Table first. Things like Read Range or data scraping will create the columns automatically.

1 Like

Hi, Thank you for your reply.

The reason for using build data table activity is to create a skeleton for the merge destination and later I want to merge multiple data tables at the back.
I also tried cloning the data table, but it didn’t work because those data table from which it was merged doesn’t have a header.

Merge Data Table doesn’t require Build Data Table to be used first to create the output table’s columns. It does that for you.

1 Like

Previously, I got an error because I couldn’t predefine the data table (Merge destination)to merge without using build data table activity.
I tried it again and it worked.
Thank you very much.

I didn’t know how to use this activity like this. thank you.
I’ll give it a try.

1 Like

Thank you very much.
I tried, it worked.

1 Like

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