你好,
我正在尝试重命名包含特定字符串的多个列标题名称,但使用现有字符串重命名它,同时删除字符串的前部。
例子:
ABC_12::ABCD_AB_ABCDEF_A_ABCDE_X_X_A1_1234_ABCD_测试_AB_测试_ABCD_TESTED_AB_A1 --> 测试_AB_测试_ABCD_TESTED_AB_A1
字符串第一部分(橙色)的字符数始终一致,字符串第二部分的字符数会从 1 到另一个不同。
到目前为止我所做的如下:
dt=current data table();
colList = dt << get column names( string );
For( i = 1, i <= N Items( colList ), i++,
If( Left( colList[i], 50 ) == "ABC_12::ABCD_AB_ABCDEF_A_ABCDE_X_X_A1_1234_ABCD",
Column( dt, colList[i] ) << Substr((colList[i],50) ), // this is the part where i m stuck.
)
);
我尝试过使用“修剪和左”。 但这不起作用。 我有一个想法,使用“设置名称”来获取第 50 个字符之后的字符串。 但必须有更好的方法来做到这一点。
你需要使用
<< set name
更改列的名称
Names Default To Here( 1 );
dt = Current Data Table();
colList = dt << get column names( string );
For( i = 1, i <= N Items( colList ), i++,
If( Left( colList[i], 48 ) == "ABC_12::ABCD_AB_ABCDEF_A_ABCDE_X_X_A1_1234_ABCD_",
Column( dt, colList[i] ) << set name( Substr( colList[i], 49 ) ), // this is the part where i m stuck.
)
);