Jump to content

Change column name between 2 databases


Ferrar Mohamed

Recommended Posts

Helloall,

I have a problem on renaming the columns.

I have a database "1" with column names like "XX0021XX"; "XX0022XX" ...

I have another database "2" where this time, I have 2 columns, with the name of the variables "XX0021XX" onthe column 1, and in the 2nd column I have the description of this variable "time" ; "Minutes"; "Temperature"; ....

 

I would like to be able to make a link between the 2 databases so that in the database "1" the name of the columns = the description of the variables in the database 2.

Link to comment
Share on other sites

You will need to import both the tables.

Then in the data canvas >. Table 1> Add a new transformation > change column names

You can select all columns whose names you want to change and use expression to change them.

 

Substitutefunction should work.

Replaces all occurrences of Arg2 in Arg1 with Arg3. The search is case sensitive.

Example:

Substitute("Test","t","ting")

Make sure you pass arguments as [Table1].column_name etc...

Link to comment
Share on other sites

This could be done with a data function that takes both of your tables as an input.

 

The 1st step would be to extract the col names of table1.

 

Then you could loop thru this list and filter the column with the variables in your table2 to extract the description.  So you get a new list with the same length.

 

Then rename your columns in table1 with the values in this list.

 

You could output the data to the original data (table1) or in a new data table.

Link to comment
Share on other sites

thank you very much for your reply,

 

Can you help me write the fonction

 

In my table1, I have all my columns with the names in (XX1, XX2, XX3 ....)

 

In my Table2, I have 2 columns, the 1st column is called "Tagname" and the rows display the names of the columns of table1 (XX1, XX2 ...), and in the 2nd column called "Description "I have the description that I would like to appear in column in Table1

 

Thank you in advance.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...