I would like to rename a column which matches particular string in column.
Check out the Video link
Can you share the sample input and expected output?
Assign activity: yourDT.Columns(0).ColumnName = “New Column Name”
The 0 is the column index, which you have to set for whichever column you want to rename. 0-based index, so if you want to rename the third column you’d use Columns(2)
Or you can reference by column name…
yourDT.Columns(“Old Column Name”).ColumnName = “New Column Name”
The problem here is the index might change and column name partially contains text
So use the column name.
Every column name is entirely text (string).
For example column name has value ‘Phone’ some other time it contains ‘Phone#’, so i need to change the whole column name as ‘Phonenumber’
Why is the column name different like this? That shouldn’t happen, and is the issue you need to resolve. What is creating the datatable? Read Range? Something else?
Are you sure you’re talking about the NAME of the column, not the data (the rows) in the column?
i am not using excel, I am using cv extract table. Thats the reason I am getting the column name differently each time
Set “AddHeaders” to false in the CV Extract Table activity’s properties. Then the columns will always be the same ie Column1 Column2 etc
the table is spanning to multiple pages, then multiple headers will be added
You can’t have multiple headers in a datatable. Each column has a name. There is only one name for a column.
Are you sure you’re talking about the column names and not the data itself, the values for the rows?
Again, turning off AddHeaders in the activity will make it so the datatable is created with generic column names.
Here’s how I have done
Used For each Activity to Loop Through Columns in Datatable
Assign Column name as you want to The Current Column Name
In my case, I wanted to Assign the value below the current column i.e. cell value of current Index of Column from 1st row.
Used index generated from the output of For Each Activity
Here’s the Assign expression
If(ExtractRecoveriesDT.Rows(0).Item(columnIndex).ToString <> “”, ExtractRecoveriesDT.Rows(0).Item(columnIndex).ToString,currentItem.ToString)
Used Conditioned-If Statement to Neglect the below error:
Assign: ColumnName is required when it is part of a DataTable.
Note: This Error Comes when There’s a null or “” value while assigning a column name
I’m using studio x and assign not available. what can I use instead?