Hello All, I am trying to substitute a simple underscore ( _ ) into each column name that has any conceivable "special" character without having to do individual if statements for each character.
Say column 1 is labeled Test1%good#parts, column 2 is labeled Test2*Fail#Opens, etc
I want the renamed column names consistent- Test1_good_parts, Test2_Fails_Opens, etc.. The data in the columns are counts (numeric and continuous or ordinal).
I've tried versions of:
spec_char = or(" ","~","`","!","@","#","$","%","^","&","*","(",")","-","+","\","|","[","[","]","<",">","?","/","." // no underscore here
);
dt = current data table();
col_name_list = dt<< get column names( string );
nc = N Cols( dt );
For( i = 1, i <= nc, i++,
one_col_name = col_name_list;
If(
Contains( one_col_name, eval(spec_char) ),
Column( i ) << set name( Substitute( one_col_name, eval(spec_char) , "_" ) )
);
);
But rep is a pattern where eval(spec_char) is looking for a character.
Is there a clean way to perform this type of group substitution?
Thanks.