你好,
我是 JSL 腳本編寫的新手。 我想堆疊來自相同通用名稱的列(達到一定長度)。 例如我的列名稱為“66_CORR_B1_W00”, 「66_CORR_B1_W01」等至「66_CORR_B1_W12」。 它們應該位於名為的單列中「66_CORR_B1」。 這將對另一個以「66_CORR_B2」開頭的列組名稱重複。 這些列可以有 20 組。 最後我想要來自 20 組列的 20 列。
這裡我附上一個範例資料表。
提前致謝。
穆罕默德·拉赫曼
以下是一個適用於您在初始討論條目中包含的範例資料的腳本。
Names Default To Here( 1 );
dt = Data Table( "Sample_data" );
ColList = dt << get column names( string, numeric );
// Loop across the column names and find only the
// columns desired
For( i = N Items( ColList ), i >= 1, i--,
If( Contains( ColList[i], "66_CORR_B" ) == 0,
ColList = Remove( ColList, i, 1 )
)
);
// Sort the columns to ensure they are in the correct order
// for the contiguous stacking
ColList = Sort List( ColList );
// Stack the data
Data Table( "Sample_data" ) << Stack(
columns( ColList ),
Source Label Column( "Label" ),
Stacked Data Column( "Data" ),
Number of Series( 2 ),
Contiguous
);
這個腳本非常基本,因為它不會檢查每個分組的列數不相等的情況,而要選擇的列不遵循一組非常好的名稱。
但它應該讓您了解如何繼續