你好,
我正在嘗試重命名包含特定字串的多個列標題名稱,但使用現有字串重命名它,同時刪除字串的前部。
例子:
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.
)
);