我有一張桌子,我想適當地格式化(也附上)

主要的複雜性來自於以下三個問題:
- 此腳本的用戶將有不同的日期格式,因為他們將使用不同語言的不同 Windows 機器。 例如,列的數據庫輸入約會時間是(總是)格式dd-mon-yyyy hh:mm:ss在西班牙語或德語中不存在。

2.用戶也會有不同的號碼格式。 所有列都將產生空數值,因為它需要逗號表示小數(3.14 不會被識別為 3,14)。
3. 在始終為日期時間的第一列之後,列可以包含數字或分類值。 在附加示例中,column3 包含註釋,因此無需更改格式。
潛在的解決方案:
問題 #1(使用語言環境的日期時間)
也許更容易驗證 JMP langague 是英文的,激活/停用忽略區域設置的選項:
dt = Current Data Table();
<BR />// TODO assert that JMP language is English
Preferences( Use JMP Locale Settings( 1 ) );
dt:datetime<< Set Data Type( Numeric ) << Modeling Type( continuous ) << Format( "Locale Date Time h:m:s" );
Preferences( Use JMP Locale Settings( 0 ) );
dt:datetime<< Format( "Locale Date Time h:m:s" );
問題#2
要將格式從英語更改為語言環境,我們可以做類似的事情。 這篇文章中的更多信息
https://community.jmp.com/t5/Martin-Demel-s-Blog/JMP-and-Excel-A-Never-ending-story-Part-2/ba-p/35099
dt = Current Data Table();<BR />
// TODO assert that JMP language is English
Preferences( Use JMP Locale Settings( 1 ) );
dt:column1 << Set Data Type( Numeric ) << Modeling Type( continuous );
Preferences( Use JMP Locale Settings( 0 ) );
dt:column1 << Set Data Type( Numeric ) << Modeling Type( continuous );
問題#3
如何使用 JMP 的最佳猜測進行編碼,以便僅將列從字符傳遞到數字?
關注這篇文章: https://community.jmp.com/t5/Discussions/Convert-data-to-numeric-Only-If-Appropriate/td-p/106692
dt = CurrentDataTable();
// TODO Assert that JMP is in English
Preferences( Use JMP Locale Settings( 1 ) );
// Convert to numeric only if nedeed
For( i = 2, i <= N Cols( dt ), i++,
isNumeric = "NO";
For( theRow = 1, theRow <= 10, theRow++,
If( Column( i )[theRow] != "" & Is Missing( Num( Column( i )[theRow] ) ) == 1,
isNumeric = "NO";
Break();
,
isNumeric = "YES"
)
);
If( isNumeric == "YES",
Column( i ) << set data type( numeric ) << Modeling Type( continuous );
Preferences( Use JMP Locale Settings( 0 ) );
Column( i ) << set data type( numeric ) << Modeling Type( continuous );
Preferences( Use JMP Locale Settings( 1 ) );
);
);
Preferences( Use JMP Locale Settings( 0 ) );
我錯過了確保 JMP 是英文的斷言,如果有更有效的方法(它可能有 100,000 行和數百列)。
你好,
“Windows”選項卡中的所有首選項都無法通過 JSL 訪問。 因此,只有解決方法是可能的。 一種建議,測試當前語言是否為英語,如果不是,則向用戶解釋如何更改它。
If( (Num( "2.1" ) == 2.1),
"English",
lw = New Window( "Warning: inappropriate formatting options",
V List Box(
Spacer Box( Size( 600, 20 ) ),
H List Box(
Spacer Box( Size( 20, 20 ) ),
V List Box(
Text Box( "Warning\!n", <<SET wrap=""> Preferences --> Windows-specific
Set \!"Display Language\!" to \!"English\!" AND
check the box next to \!"Use JMP language rather than System locale settings,...\!n
Then re-start this program\!n",
<<SET wrap=""></SET></SET>
最好的祝福
貝恩德
我可能沒有完全理解這個要求。 據我所知,所有列都是字符,除了名稱之外,沒有其他信息可以識別日期時間列。 如果該名稱始終相同,則無需遍歷列,只需在腳本中命名即可。 另一種方法是編寫一個小對話框,讓用戶選擇要轉換的列。 我也不完全明白目標是什麼:日期應該在世界各地以相同的格式顯示,還是應該根據本地設置顯示? 目前,我假設各個列始終具有相同的名稱,並且日期格式應以本地格式顯示。 然後附加的腳本至少可以完成需要完成的部分工作。