Operator to set all column names using a list of stringsHi. 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.
ScriptingRe: Operator to set all column names using a list of stringsHi,
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 );
);
);
);