cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Chan
Level I

Help getting rows to populate after renaming columns

Hello

I am trying to create a JMP script that will rename column names that are in another language to English text and create a new datatable with the new column names.  In the script below the column names get renamed below the original column names and the rows of data are lost.  Any suggestions? Please help with scripting answers if you have them!

 

Thanks,

 

Eve

 

 

Chan_0-1618001404957.png

 

2 REPLIES 2
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Help getting rows to populate after renaming columns

Not sure exactly what you're trying to do with the code in the picture and how generic the solution must be. However, if you just want a copy of a file but with translated column names, and a property that stores the original name, a "subset" should work. I this way, not only the rows but also column properties, cell colors etc. are preserved. 

 

A simplified example:

dt = Open("$SAMPLE_DATA/Big Class.jmp");
oldnames = dt << get column names(string);
// List of corresponding column names in another laguage. Could be retrieved from a lookup table (or associative array)
newnames = {"namn", "ålder", "kön", "höjd", "vikt"}; 

// Make a copy of original table
dtt = dt << Subset(All rows, Selected columns only(0));

// Add a custom property with old name and rename columns
For(i = 1, i <= N Items(oldnames), i++,
    Column(dtt, i) << set property("OldName", oldnames[i]);
    Column(dtt, i) << set name(newnames[i]);
);
txnelson
Super User

Re: Help getting rows to populate after renaming columns

I am not sure if I am guessing correctly on what you are attempting to do, but if you are looking to transfer the data from your dd to the ddt data table, you are not showing anything in your code that is doting that.  Here is a lint of code, that if placed after your 21st line would copy the data from the dt data table to the ddt data table.

Column( dtt, colList[i] ) << set values( Column( dt, OldName ) << get values );
Jim