How to add multiple column in existing data table

Hiii, I’m New To UiPath studio,and used UiPath community edition 2023.4
I want add 30 columns with a default 0 value in the existing data table,
How can add or which activity is used to add column,
As per I knowledge add data column activity is used for adding one column , but I want multiple columns .
Please guide me

@ashwini.mali :You can creat Excel file with whatever Data you want & use Read Range workbook activty, the output will be Datatable.

i want only add columns in existing excel @avinash_ghanwat1

@ashwini.mali : In that case you need to use Read range workbook activity & then you need to use Add data column activity maybe inside Loop

how did you get the column names you want to add?

Like from where or format

is your requirement is to add to excel file or datatable?

Regards

Hi @ashwini.mali

Easy way to do this would be creating a list/Array of Column Names.
Use Add Data Column method pass the loop variable in this and Default Value as 0.
Workflow Screenshot
image
Properties of Add Data Column
image

Thanks

@avinash_ghanwat1 @adiijaiin but using add column activity ,add only one column ,so in that case I want 30 time use add data column activity .
is any activity is present for add multiple columns .
like multi assign activity

@ashwini.mali : could you please help me to understand what will be the column name as in that case you can use While loop for iterating for 30 times

Hi @avinash_ghanwat1

Use build data datatable activity and add columns and then use merge datatable activity to resolve the issue

Thanks
ASHWIN.S

@AshwinS2 can set default value as 0 ,
how merge 2 data table

Hi @ashwini.mali

You won’t have to use Add Data Column multiple times. if you loop through a list of all the columnnames

Hi @ashwini.mali

You have the existing datatable read it as dt 1 and use build datatable and add columns in dt 2

You can use merge datatable as it is

Thanks
Ashwin.S

hi @ashwini.mali

You can use something like this,
Assuming a Datatable that you have used using read range, instead of that I just used a build data table for dummy data.

and then used loop and inside loop add data column,

you can check the excel file.
AddColumns.xaml (8.9 KB)
Students.xlsx (7.3 KB)

Regards,
Aditya

Hi @ashwini.mali ,

Refer the following thread:

Regards,

thank you so much ,issue resolved

how to apply if condition on data table
Check columns are present in data table or not ,
If columns are not present in data table then create columns,
else column present then skip add column step and proceed to next step
@adiijaiin @vishal.kp @AshwinS2 @LAKSHMI_NARAYANA_PEMMASAN @avinash_ghanwat1

hi @ashwini.mali

You can use something like this inside an if condition:
dtStudents.Columns.Contains(PassColumnName here)

Thanks
Happy Automation

@adiijaiin thank you for reply
Above solution is work for 1 column ,
i want check 30 columns
which activity use?

It is inside the loop, so it’ll be checking for all the columns that we have in the list.

@adiijaiin thank you so much
got it ,one more question,
can we use build data table activity in if condition ,for create multiple columns