嗨,
我是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
);
该脚本非常基本,因为它不检查每个分组的列数不相等的情况,要选择的列不遵循一组非常好的名称。
但它应该让你知道如何进行