Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Highlighted
nikles
Level V

Set column names more efficiently?

Hi.  I'm looking for a scripting method to efficiently change the column names in my table to names I have contained in a list, without using a for loop.  Is there an operator or function that can perform this?  I'm thinking something like: dt << Set Column Names(newcolname_lis)?

 

With a for loop, I can do it this way:

...
col_lis = dt << Get Column Names("String"); For(i=1, i<=NItems(col_lis), i++, dt:i << Set Name(newname_lis[i]); );


But, my tables can contain > 20k columns, and this takes several minutes.  Any ideas on speeding this up?

 

Thanks.

 

 

 

5 REPLIES 5
Highlighted
ThuongLe
Level IV

Re: Set column names more efficiently?

I have a crazy idea:
-Create blank table with your desired column names
-Copy and paste data from original table to newly-created one
Hope it helps
Highlighted
nikles
Level V

Re: Set column names more efficiently?

Thanks! Not a crazy idea at all. I tried this as well, but creating the table is equally slow.
Highlighted
txnelson
Super User

Re: Set column names more efficiently?

I do not see a different method in the renaming of the column names.  However, I like your idea of being able to do that.  You need to add your idea to the JMP Wish List.

Jim
Highlighted
nikles
Level V

Re: Set column names more efficiently?

Thanks for the advice Jim. At least I have some confidence that the way I'm currently doing it is the fastest. Will add to the wish list.
Highlighted
nikles
Level V

Re: Set column names more efficiently?

Article Labels