cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • See how to interactively organize and restructure data for analysis. Register for May 29 webinar, 2pm US ET.

JMP Wish List

We want to hear your ideas for improving JMP. Share them here.
Choose Language Hide Translation Bar

Operator to set all column names using a list of strings

Hi.  I'm looking for a scripting method to change the column names in my table to names I have contained in a list.  I'm thinking something like: dt << Set Column Names(newcolname_lis)?  This command would change the name of the ith column in the table to the ith item in newcolname_lis, starting at column 1.

 

The reason for this request:

I have tables that can contain >20k columns.  I need to change the column names to merge with the rest of my data tables.  Using a For loop to change the names takes several minutes.  Ideally this could be done using a command in a few seconds.

 

This is a follow up to a question I posted earlier:

https://community.jmp.com/t5/Discussions/Set-column-names-more-efficiently/m-p/311439#M56450 

 

Thanks.

2 Comments
guillaumebugnon
Level V

Hi,

 

I have one function able to rename a column based on string pattern. You can maybe try to adapt it.

 

function_RenameCol = Function({ dt, strpattern, strreplace},
						lstCol	=	dt <<	Get column names( string );
						For( icol = 1, icol <= Nitems(lstCol), icol++,
							if (Contains( lstCol[icol],strpattern) >= 1,
								newname = Munger(lstCol[icol],0,strpattern,strreplace);
								Column( dt, icol ) << Set Name( newname );
							);
						);
					);
Ryan_Gilmore
Community Manager
Status changed to: Archived
We are archiving this request. If this is still important please comment with additional details and we will reopen. Thank you!