基于使用JSL的正则表达式将N列(对于M参数)组合成每个参数的唯一列你好,
我有N列数字数据,某些列对于给定行是空白的(因此感兴趣的参数是按列分散的)
N列表示M个参数,我希望将每个M参数组合成一个列。
理想情况下,我想获得有关如何在JSL中编写脚本的指导,并将一些表单或正则表达式合并到一起,以便我可以根据关键字为大量列执行此操作
附加一个非常基本的样本数据表。
Re:基于使用J的正则表达式,将N列(对于M参数)组合成每个参数的唯一列嗨,mpanggabean!
请告诉我们这是否正确:您希望堆叠包含例如“param1”和“domain1”和“vdd”的列,并且还可能将“paramx”和“domainy”和“zzz”列为单独的列。
您预期从一开始到结尾有多少列和行?
Re:基于使用J的正则表达式,将N列(对于M参数)组合成每个参数的唯一列有了这些东西,它在很大程度上取决于你可以安全地假设数据(以及你不能做什么!)。如果我理解正确,下面的代码适用于给定的样本表(和'类似'表)。它可以推广,或者,通过更多的工作,建立公式列(通过利用 @Jeff_Perkinson 使用上面的“Sum()”。
NamesDefaultToHere(1);
dt = CurrentDataTable();
// First data column
fdc = 2;
// Number of columns in a group
nc = 2;
// Number of groups
ng = (NCol(dt) - 1) / nc;
// Loop over each group and add a 'sum' column for each
for(g=1, g <=ng, g++,
firstCol = fdc + (g-1)*nc;
lastCol = firstCol + (nc-1);
gData = dt << getAsMatrix(firstCol::lastCol);
// Replace ',' by '0' so 'VSum()' works as required
gData[loc(IsMissing(gData))] = 0;
// Get the sum of columns using 'VSum()' (need to transpose, and back again)
sumVals = Transpose(VSum(Transpose(gData)));
// Make the new column
cName = Column(dt, firstCol) << getName;
dt << NewColumn(cName||"_Sum", Numeric, Continuous, Values(sumVals));
);
Re:基于使用J的正则表达式,将N列(对于M参数)组合成每个参数的唯一列杰夫,
是的,应该只有一个列具有参数值,但是,参数和子参数太多。例如,param1可以具有:param1_domain1_vdd1,param1_also_domain1_vdd1,param1_domain1_vdd2,param1_also_domain1_vdd2,param1_domain1_vdd3,param1_also_domain1_vdd3等。只想在同一域和相同的vdd中合并一个参数,并且可能有更大的参数总数。 因此,我想避免选择和总结太多次。还有什么建议?
谢谢你的简单起点!
Re:基于使用J的正则表达式,将N列(对于M参数)组合成每个参数的唯一列如果您可以确定只有一个带参数值的列,则可以使用Sum()函数。这是因为Sum()忽略了缺失值。因此参数值的总和将是非缺失参数的值。

Re:基于使用J的正则表达式,将N列(对于M参数)组合成每个参数的唯一列 @mpanggabean ,
以下脚本将帮助您将列列表分成2个列表。这两个清单会告诉你
1。什么是包含参数的列名称
2。表中可用的唯一参数是什么。
从这里或使用此基本脚本,您可以根据自己的选择操作数据。
Clear Log () ; Clear Globals();
dt = Current Data Table() ; // Getting a reference to the table . Alternatively you can open the file using Open()
ColNames = dt << Get Column Names("String"); // Acquire names of columns in table as string
ParameterColList = list(); // Intialize an empty list
ParamsList = list() ;
KeyWord = "param"; // Define Keyword all your parameters have
CommonDelim = "_";
for(i = 1 , i <= N Items(ColNames), i++,
If(!IsMissing(Regex(Char(ColNames[i]),KeyWord)),
Insert Into(ParameterColList,ColNames[i]);
If(Contains(ColNames[i],CommonDelim),
Pos = Contains(ColNames[i],CommonDelim); // Identify where the common delimiter is
Insert Into(ParamsList,Substr(ColNames[i],1,Pos-1));
);
);
);
Show(ParameterColList); // Display List
Show(ParamsList);