如果列不存在,則編寫腳本跳過更改列大家好,
如果目標列不存在,是否有一種方法可以自動忽略一段腳本? 例如,我有如下所示的腳本,有時沒有可用的「數字 C」(它是一個自動化部分,可能有也可能沒有 3 個變數)。 目前,當找不到「數字 C」時,腳本會在該片段上停止;理想情況下,我希望製作一個帶有多個“數字#”的腳本,如果該腳本不存在,它將自動忽略該腳本:
數據表( “1 月 5 日集” ) ;
柱子( “柱子” ) <<資料類型(數位) ;
柱子( “柱子” ) <<造型類型(連續的) ;
柱子( “數據” ) <<資料類型(數位) ;
柱子( “數據” ) <<造型類型(連續的) ;
柱子( “數字A” ) <<資料類型(數位) ;
柱子( “數字A” ) <<造型類型(連續的) ;
柱子( “數字B” ) <<資料類型(數位) ;
柱子( “數字B” ) <<造型類型(連續的) ;
柱子( “數位C” ) <<資料類型(數位) ;
柱子( “數位C” ) <<造型類型(連續的) ;
感謝您,
喬
回覆:如果列不存在,則編寫腳本跳過更改列這是一個腳本,它採用您所說的嘗試過的內容,並對其進行更正,以便它可以工作。我還對腳本進行了註釋,以幫助理解每個語句的作用
// Set a variable "dt" to point to the data table you want to work on
// In the example you showed, it was a table called "Jan 5 Subset"
dt = Data Table("Jan 5 Subset");
// Now request to get from the data table, now referenced by the
// variable "dt" and return the list as strings
// Using the Contains function, we will check to see if a column
// named "Numerical A" is found in the returned list of column
// names. If it is, the comparison will be true and the statements
// following the "," will be executed
IF( Contains(dt << Get column names(string), "Numerical A"),
// Set the Data Type and Modeling Type for the column "Numerical A"
Column("Numerical A") <<DATA type=""></DATA>回覆:如果列不存在,則編寫腳本跳過更改列第二段腳本完美運行,非常感謝!回覆:如果列不存在,則編寫腳本跳過更改列嗨吉姆,
感謝您的快速回覆。 我已經嘗試過頂部功能:
dt =數據表( “1 月 5 日集” );
如果(包含( dt < <得到柱子名稱(字串), “柱子” ),
柱子( “柱子” ) < <數據類型(數字) < <造型類型( 連續的 )
);
但是我不確定腳本中“(字串)”的位置應該放什麼?
眼下該腳本似乎在「Send Expects Scriptable Object」這一行失敗。 我目前的腳本是:
如果(包含( dt <<取得列名(細繩) , “數字A” ) ,
“數字A” ) <<資料類型(數位) <<造型類型(連續的) ;
如果我在這裡遺漏了一些非常明顯的東西,我深表歉意,提前致謝。
回覆:如果列不存在,則編寫腳本跳過更改列我有幾種方法可以做到這一點......
第一種是將需要限定的語句放在 IF 函數中。最正式的方法是從資料表中取得列名,然後根據是否找到該列來確定 IF 條件
dt = Data Table( "Jan 5 Subset" );
If( Contains( dt << get column names( string ), "Column" ),
Column( "Column" ) << Data Type( Numeric ) << Modeling Type( Continuous )
);
第二種方法是使用 Try 函數讓 JMP 忽略它發現的任何錯誤
Try( Column( "Column" ) << Data Type( Numeric ) << Modeling Type( Continuous ) );
該語句可能會失敗,但JMP將繼續執行