如何將列屬性導入 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 中的哪些列?