使用 JSL 堆叠多个带条件的参数我得到了一个具有多个参数的数据集,其格式为“TestNumber;TestName”。 我知道我们可以轻松地手动进行操作。 但
我想用 JSL 以一种聪明的方式将它们全部堆叠起来。 如何在 JSL 中执行此操作? 请指教。 谢谢
回复:使用 JSL 堆叠多个带条件的参数嗨,舞会,
感谢您的精彩提示! 它像冠军一样工作!回复:使用 JSL 堆叠多个带条件的参数您需要将列名称转换为字符串。另外 one_col 也不是列表。这是更正后的代码。我鼓励你
a) 阅读脚本手册
b) 经常检查日志中的变量值、错误消息等。
c) 继续使用此论坛
Names Default To Here( 1 );
sourceTable = Data Table( "FINAL" );
col_list = sourceTable << get column names( continuous, string );
stackcols = {};
//one_col = {};
For( i = 1, i <= N Items( col_list ), i++,
one_col = col_list[i];
show(one_col, i);
If( Regex( one_col, "(\d+);(\S+)" ) == one_col,
Insert Into( stackcols, one_col )
);
);
resultTable = sourceTable << Stack(
columns( stackcols ),
Source Label Column( "Label" ),
Stacked Data Column( "Data" )
);
resultTable << setName( (sourceTable << getName) || " Stacked Data" );回复:使用 JSL 堆叠多个带条件的参数谢谢pmroz。 我根据你的建议修改了脚本,但似乎遇到了错误。
Names Default To Here( 1 );
sourceTable = Data Table( "FINAL" );
col_list = sourceTable << get column names( continuous );
stackcols = {};
one_col = {};
For( i = 1, i <= N Items( col_list ), i++,
one_col = col_list[i];
If( Regex( one_col, "(\d+);(\S+)" ) == one_col,
Insert Into( stackcols, one_col )
);
);
resultTable = sourceTable << Stack(
columns( stackcols ),
Source Label Column( "Label" ),
Stacked Data Column( "Data" )
);
resultTable << setName( (sourceTable << getName) || " Stacked Data" );
/****************************************
访问或评估 'Regex' 时出现模式匹配未知错误,Regex/*###*/(one_col, "(\d+);(\S+)")
回复:使用 JSL 堆叠多个带条件的参数col_list = {"2010;PinShort@CLK", "2011;PinShort@IO", "2012;PinShort@VDD", "Label", "Data"};
stackcols = {};
for (i = 1, i <= nitems(col_list), i++,
one_col = col_list[i];
if (regex(one_col, "(\d+);(\S+)") == one_col,
insertinto(stackcols, one_col);
);
);
回复:使用 JSL 堆叠多个带条件的参数嗨,纳尔逊,
我完全理解。 然而我的问题正是您上面提到的,“如何使用我的条件填充 stackCols 列表”,并使用正则表达式“(\d+);(\S+)”作为参数。
不管怎么说,还是要谢谢你。 我会尝试自己尝试并犯错。回复:使用 JSL 堆叠多个带条件的参数@OneNorthJMP ,
我相信伊恩向您展示的正是您所要求的。Ian 展示的是您需要做的就是在 JSL 中创建一个列表 (stackCols),其中包含您想要堆叠的列的名称,然后运行脚本底部的代码段:
resultTable = sourceTable << Stack(columns(stackCols), Source Label Column( "Label" ), Stacked Data Column( "Data" ));
resultTable << setName((sourceTable << getName)||" Stacked Data");
因此,问题是您如何填充 stackCols 列表。如何做到这一点取决于您的需求。它可能就像使用一样简单
stackCols = dt << get column names( continuous );
填充列表。或者可能需要更复杂的方法。但 Ian 展示的是,使用数据表中当前拥有的任何数据运行 Stack Platform 是多么简单。
回复:使用 JSL 堆叠多个带条件的参数嗨伊恩,
感谢您的回复。 也许我的解释不太清楚。 我想让 JSL 脚本能够适应不同输入表中的不同参数。
例如,输入表1,我有2列。 我必须将 JSL 修改为以下内容。
Data Table( "FINAL.jmp" ) << Stack(
columns(
:Name( "2010;PinShort@CLK" ),
:Name( "2011;PinShort@IO" ),
:Name( "2012;PinShort@VDD" ),
:Name( "2013;PinShort@LA" ),
:Name( "2014;PinShort@LB" ),
:Name( "2030;PinOpen@CLK" )
),
Source Label Column( "Label" ),
Stacked Data Column( "Data" )
)
例如,输入表 2,如果我有 3 列。 我必须将 JSL 修改为以下内容。
Data Table( "FINAL.jmp" ) << Stack(
columns( :Name( "2010;PinShort@CLK" ), :Name( "2011;PinShort@IO" ), :Name( "2012;PinShort@VDD" ), ),
Source Label Column( "Label" ),
Stacked Data Column( "Data" )
)
那么,如果我有一千列怎么办? 那我必须一一手动输入吗?或者手动执行此操作? 是的,我当然可以手动完成。 但这不是我的目标,我希望有一个脚本可以读取正则表达式来查找堆栈参数“(\d+);(\S+)”,无论我的输入表是什么。
回复:使用 JSL 堆叠多个带条件的参数详细信息将取决于您所说的“我的表是动态的”时的确切含义以及您需要多少智能。
但是,例如,对 JMP 生成的代码进行一些小的更改,您可以:
NamesDefaultToHere(1);
sourceTable = DataTable("FINAL");
stackCols =
{
:Name( "2010;PinShort@CLK" ),
:Name( "2011;PinShort@IO" ),
:Name( "2012;PinShort@VDD" ),
:Name( "2013;PinShort@LA" ),
:Name( "2014;PinShort@LB" ),
:Name( "2030;PinOpen@CLK" ),
:Name( "2031;PinOpen@IO" ),
:Name( "2032;PinOpen@VDD" ),
:Name( "2033;PinOpen@LA" ),
:Name( "2034;PinOpen@LB" ),
:Name( "2200;Ana_Idd_noClock@VDD" ),
:Name( "2360;Dig_ATE_FUN_00_001_Authenticate" ),
:Name( "2361;Dig_ATE_FUN_00_003_DisableReset" ),
:Name( "2380;Dig_ATE_FUN_00_004_GetVersion" ),
:Name( "2440;SyncPulse_and_capResponse_0x90" ),
:Name( "2441;Ana_Pads_ATE_VOL_0uA@IO" ),
:Name( "2442;Ana_Pads_ATE_VOH_0uA@IO" ),
:Name( "2443;Ana_Pads_ATE_VOL_0uA_IDD@VDD" ),
:Name( "2444;Ana_Pads_ATE_VOL_0uA_Rcont_GND@VSS" )
};
resultTable = sourceTable << Stack(columns(stackCols), Source Label Column( "Label" ), Stacked Data Column( "Data" ));
resultTable << setName((sourceTable << getName)||" Stacked Data");
“sourceTable”和“stackCols”的值将由用户界面或某些较大的 JSL 脚本设置。
回复:使用 JSL 堆叠多个带条件的参数嗨伊恩,
我已经知道了。 事情是我的桌子是动态的。 我不想每次有不同的数据表时都修改我的脚本。 但我的参数数据格式是固定的。 因此,在 JSL 中编写此代码应该是一种明智的方法。回复:使用 JSL 堆叠多个带条件的参数如果可以的话,让 JMP 为您完成工作是个好主意 - 通常您只需“手动”执行一次操作,然后使用 JMP 自动生成的代码。
在这种情况下,如果您执行“表>堆栈”:

点击“确定”会生成一个新表,其中包含名为“源”的已保存脚本。 如果右键单击关联的绿色“运行”图标,则可以选择“编辑”,这将为您提供以下脚本:
Data Table( "FINAL.jmp" ) << Stack(
columns(
:Name( "2010;PinShort@CLK" ),
:Name( "2011;PinShort@IO" ),
:Name( "2012;PinShort@VDD" ),
:Name( "2013;PinShort@LA" ),
:Name( "2014;PinShort@LB" ),
:Name( "2030;PinOpen@CLK" ),
:Name( "2031;PinOpen@IO" ),
:Name( "2032;PinOpen@VDD" ),
:Name( "2033;PinOpen@LA" ),
:Name( "2034;PinOpen@LB" ),
:Name( "2200;Ana_Idd_noClock@VDD" ),
:Name( "2360;Dig_ATE_FUN_00_001_Authenticate" ),
:Name( "2361;Dig_ATE_FUN_00_003_DisableReset" ),
:Name( "2380;Dig_ATE_FUN_00_004_GetVersion" ),
:Name( "2440;SyncPulse_and_capResponse_0x90" ),
:Name( "2441;Ana_Pads_ATE_VOL_0uA@IO" ),
:Name( "2442;Ana_Pads_ATE_VOH_0uA@IO" ),
:Name( "2443;Ana_Pads_ATE_VOL_0uA_IDD@VDD" ),
:Name( "2444;Ana_Pads_ATE_VOL_0uA_Rcont_GND@VSS" )
),
Source Label Column( "Label" ),
Stacked Data Column( "Data" )
)
您可以使该脚本变得更智能,但如果您只是添加新行,它将正常工作(只要它需要的列仍在源表中)。