如何将列属性导入 JMP 数据文件?你好,
新的挑战:
我创建了列属性:测试编号在第一个文件中。 每个测试都有唯一的测试编号,可以在列属性中找到,如下面突出显示的红色圆圈所示:

我有一个包含 1 列(测试)的第二个 JMP 文件:

我正在尝试编写一个脚本,该脚本可以从第一个文件中复制测试编号,并在第二个文件中的测试中分配最低值,因此我的输出将相对如下所示:
测试编号在第一个文件的列属性中定义
例如燃烧,冷却,静电放电= 最小值[测试次数] = 21
输出:

有什么建议么?
谢谢
Re: 如何将列属性导入 JMP 数据文件?很好地尝试 If ..... 但分支需要更大的范围。见下文......
Names Default To Here( 1 );
dt1 = Data Table( "1st_file" );
dt2 = Data Table( "2nd file" );
dt2 << New Column( "Test Number" );
For( i = 1, i <= N Rows( dt2 ), i++,
k = 1;
While( Word( k, dt2:test[i], "," ) != "",
theWord = Word( k, dt2:test[i], "," );
If( theWord != "N/A",
If( k == 1,
theTest = Column( dt1, theWord ) << get property( "Test Number" ),
theCompare = Column( dt1, theWord ) << get property( "Test Number" );
If( theCompare < theTest,
theTest = theCompare
);
)
,
theTest = 0
);
k++;
);
dt2:test number[i] = theTest;
);Re: 如何将列属性导入 JMP 数据文件?你好@txnelson ,
最后一个问题
我有一些不适用在看起来像这样的行中进行测试。 我想分配测试编号作为0至不适用行

我添加了一个如果()声明,但我不确定我是否正确输入了声明。 你能看看吗?
Names Default To Here( 1 );
dt1 = Data Table( "1st_file" );
dt2 = Data Table( "2nd file" );
dt2 << New Column("Test Number");
For( i = 1, i <= N Rows( dt2 ), i++,
k = 1;
While( Word( k, dt2:test[i], "," ) != "",
theWord = Word( k, dt2:test[i], "," );
If( k == 1,
theTest = Column( dt1, theWord ) << get property( "Test Number" ),
theCompare = Column( dt1, theWord ) << get property( "Test Number" );
If( theCompare < theTest,
theTest = theCompare
);
);
k++;
<STRONG>If( Word( 1, dt2:test[i], "," ) == N/A,
dt2:test number[i] = 0;
);</STRONG><BR /> );
dt2:test number[i] = theTest;
);
Re: 如何将列属性导入 JMP 数据文件?Names Default To Here( 1 );
dt1 = Data Table( "1st_file" );
dt2 = Data Table( "2nd file" );
For( i = 1, i <= N Rows( dt2 ), i++,
k = 1;
While( Word( k, dt2:test[i], "," ) != "",
theWord = Word( k, dt2:test[i], "," );
If( k == 1,
theTest = Column( dt1, theWord ) << get property( "Test Number" ),
theCompare = Column( dt1, theWord ) << get property( "Test Number" );
If( theCompare < theTest,
theTest = theCompare
);
);
k++;
);
dt2:test number[i] = theTest;
);Re: 如何将列属性导入 JMP 数据文件?你好@txnelson ,
如果可能的话,你能把代码贴出来吗? 我有完成这项任务的最后期限。 我尝试对少于 3 个 Test 但未执行的行使用 while() 函数。 讨论变得冗长而混乱。
Re: 如何将列属性导入 JMP 数据文件?你好@txnelson ,
我有个建议。 我可以创建一个列表并将测试编号存储在列表中并使用语法吗分钟()分配最低的号码?
For (i=1, i<=2, i++,
theWord = word(i,dt2:test[1],",");
theTest() = column( dt1, theWord ) << get property("Test Number");
dt2:test number[1] = Min(theTest);
);
Re: 如何将列属性导入 JMP 数据文件?这个在我身上.....我正在用错误的变量进行测试。进行比较的语句应为
If( theCompare < theTest,
theTest = theCompare
);
但是您还有另一个问题......脚本假定您在列 Test 的每一行中始终有 3 个值。当少于 3 个时,脚本将失败,或者如果超过 3 个,它将永远不会与 4,5 等项目进行比较。
查看 While() 函数以了解如何解决此问题。
下面是为比较语句更正的代码
Names Default To Here( 1 );
dt1 = Data Table( "1st_file" );
dt2 = Data Table( "2nd file" );
For( i = 1, i <= N Rows( dt2 ), i++,
theWord = Word( 1, dt2:test[i], "," );
theTest = Column( dt1, theWord ) << get property( "Test Number" );
theWord = Word( 2, dt2:test[i], "," );
theCompare = Column( dt1, theWord ) << get property( "Test Number" );
If( theCompare < theTest,
theTest = theCompare
);
theWord = Word( 3, dt2:test[i], "," );
theCompare = Column( dt1, theWord ) << get property( "Test Number" );
If( theCompare < theTest,
theTest = theCompare
);
dt2:test number[i] = theTest;
);
Re: 如何将列属性导入 JMP 数据文件?你好@txnelson ,
您建议的逻辑不适用于某些条件。 如果我更改测试的顺序,脚本会生成不正确的值,并且第 4、5、6 行的测试编号为空白
测试 = 冷却、ESD、电流
测试编号 = 测试编号的最小值[32, 87, 23] = 23
第 2 列中的测试编号应为 23。

我更正了您建议的陈述:
For (i=1, i<=nrows(dt2), i++,
theWord = word(1,dt2:test[i],",");
theTest = column( dt1, theWord ) << get property("Test Number");
theWord = word(2,dt2:test[i],",");
theCompare = column( dt1, theWord ) << get property("Test Number");
If( theCompare < theWord, theTest = theCompare );
theWord = word(3,dt2:test[i],",");
theCompare = column( dt1, theWord ) << get property("Test Number");
If( theCompare < theWord, theTest = theCompare );
dt2:test number[i] = theTest;
);
Re: 如何将列属性导入 JMP 数据文件?问题在于这个声明
theWord = word(i,dt2:test[i],",");
您的 For() 循环使用“i”作为它的索引,它从 1 到 N Rows(dt2) 不等。因此它从 1 到 5 不等。您在 Word() 函数中的 2 个不同位置使用“i”索引。dt2:Test[i] 将读取第 1 到 5 行。但是,如果您查看 JSL 语法参考对于 Word() 函数
Word(n|[first last], string, <delimiter>, <Unmatched(result string)>)
Description
Returns the nth item of the string, where words are sub-strings separated by any number of
any characters in the delimiter argument.
Arguments
n The position of the word being extracted.
[first last] A matrix that defines the beginning and end word range to return.
string The string that is evaluated.
delimiter (Optional) The character used as a boundary. If delimiter is absent, an ASCII
space is used. If delimiter is the empty string, each character is treated as a separate
word. If delimiter is an empty string, each character is treated as a spate word.
Unmatched(result string) The string to print if no match is found.
Examples
This example returns the last name:
Word( 2, "Katie Layman" );
Note
See “Item(n|[first last], string, <delimiter>, <Unmatched(result string)>, <Include
Boundary Delimiters(Boolean)>)” on page 35 for examples of how Word() differs from
Item().
您为要删除的 Word 指定的内容取决于“i”的值。那不是你想要的。在我提供的代码中,如果你看的话,它要么是 1,2,要么是 3
所以你需要调整它
Re: 如何将列属性导入 JMP 数据文件?你好@txnelson ,
我在您发布的脚本中使用了 For 循环。
names default to here(1);
dt1 = data table("1st_file");
dt2 = data table("2nd file");
dt2 << New Column("Test Number");
For(i=1, i<=nrows(dt2),i++,
theWord = word(i,dt2:test[i],",");
theTest = column( dt1, theWord ) << get property("Test Number");
theWord = word(i,dt2:test[i],",");
theCompare = column( dt1, theWord ) << get property("Test Number");
If( theCompare < theWord, theTest = theCompare );
theWord = word(i,dt2:test[i],",");
theCompare = column( dt1, theWord ) << get property("Test Number");
If( theCompare < theWord, theTest = theCompare );
dt2:test number[i] = theTest;
);
<BR />它没有为第二个文件的第 4 行和第 5 行分配值

我很确定我在 For 循环中犯了一些错误。 你能不能给我一些指导。
Re: 如何将列属性导入 JMP 数据文件?@txnelson你是天才。 是的,你是对的,我将开始学习。 非常感谢Re: 如何将列属性导入 JMP 数据文件?@杰克史密斯12您已经在前面的示例中看到了所有这些语句和函数。您需要开始尝试自己将它们组合在一起。在计算中,您学习的唯一方法是犯错误并找出问题所在。因此,下面是您的 2nd_file 中单个条目的流程,它返回最小测试编号。您应该能够将其余代码放在一起。
names default to here(1);
dt1 = data table("1st_file ");
dt2 = data table("2nd file ");
dt2 << New Column("Test Number");
theWord = word(1,dt2:test[1],",");
theTest = column( dt1, theWord ) << get property("Test Number");
theWord = word(2,dt2:test[1],",");
theCompare = column( dt1, theWord ) << get property("Test Number");
If( theCompare < theWord, theTest = theCompare );
theWord = word(3,dt2:test[1],",");
theCompare = column( dt1, theWord ) << get property("Test Number");
If( theCompare < theWord, theTest = theCompare );
dt2:test number[1] = theTest;
确保您理解代码的每一行,如果您不理解,请针对您不理解的内容提出具体问题。
Re: 如何将列属性导入 JMP 数据文件?你能举一个快速入门的例子吗?Re: 如何将列属性导入 JMP 数据文件?在 1st_file 中,每列只有 1 个列属性,测试编号.....没有测试名称。
假设测试名称的每一列的第二个列属性应该在 1st_File 数据表中,那么我相信访问它们的最佳方法是创建一个关联数组。 然后遍历每一列,提取 2 列属性,并将它们放入关联数组中。 最后,将逐行遍历 2nd_file,并获取列 Test 的值,这将是对关联数组的简单查找,以获得所需的测试编号。Re: 如何将列属性导入 JMP 数据文件?你好@txnelson ,
右键单击列属性,您将找到测试编号和测试名称
Re: 如何将列属性导入 JMP 数据文件?怎么知道在计算 2nd_file 中特定行的值时评估了 1st_file 中的哪些列?