此加載項將從數據交換格式或DIF文件創建JMP數據表。 該文件格式起源於1980年的Visicalc,作為在電子表格程序之間傳輸數據的機制。
在示例代碼中,我提供了4種機制來檢查所需的標頭,一次只有一個活動。
有關其他信息正則表達式看到 @Craige_Hales '博客文章以及對Pat Match選項的見解見 JSL Cookbook 。
默認情況下,我已經實現了選項2:Pat Match以進行錯誤檢查。
必需的標題項:
- 標題
- 向量
- 元組
- 數據
標題格式,即標題屬性的結構
<<屬性名稱>>
<<矢量數>>,<<數值>>
<<“字符串值”>>
哪裡,|
<< Attribute_Name >>是(通常)32個或更少字符的符號/標記
<<矢量編號>> 整個文件是0
除非另有說明,否則<<數值>>為0
<<“字符串值”>>是\!“\!” (雙引號之間沒有空格)如果不使用的話
可選標題項: 請注意,在加載項的開發過程中未測試這些可選標頭
- 評論
- 標籤
- 尺寸
- Truelength
- 單位
- DispalyUnits
數據:
<<數據類型指示符>>,<<數值>>
<<“字符串值”>>
哪裡,
<<數據類型指示符>>是三個值-1,0,1之一
-1 - 是一個特殊的數據值
<<“字符串值”>> = BOT或EOD
0 - 數字帶符號的十進制數
<<數值>>是數值數據
<<“字符串值”>> =是值指標之一(V,NA,ERROR,TRUE,FALSE)
1 --string數據值
<<數值>> = 0
<<“String Value”>> =字符串數據值
errorhdrchkExpr = Expr(
regex_hdrs = "(TABLE|VECTORS|TUPLES|DATA)";
matrix_hdrs = { "TABLE", "VECTORS", "TUPLES", "DATA" };
rqd_hdrs = { TABLE, VECTORS, TUPLES, DATA };
// Option 1: Find match using Regex with check for required headers
thematch = Regex( lines, regex_hdrs );
If( IsMissing(thematch),
errnum_desc = "Error: A required header is missing";
errhdrnum = 0;
Break();
,
errhdrnum = 1
);
// Option 2: Find specific match using Pat Match with check for required headers
err_List = {};
For( e = 1, e <= Nitems( matrix_hdrs ), e++,
thematch = patMatch( txtfile, matrix_hdrs[e] );
If( thematch == 0,
errnum_desc = Concat("Error ", char( e ), ": ", "A required header ", matrix_hdrs[e], " is missing.");
Insert Into( err_List, errnum_desc);
errhdrnum = 0;
Break();
,
errhdrnum = 1
)
);
// Option 3: Find specific match using LOC with check for required headers
err_List = {};
For ( e = 1, e <= Nitems( rqd_hdrs ), e++,
If( Loc( {lines}, rqd_hdrs[e] ) != [1],
errnum_desc = Concat("Error ", char( e ), ": ", "A required header ", rqd_hdrs[e], " is missing");
Insert Into( err_List, errnum_desc);
errhdrnum = 0;
Break();
,
errhdrnum = 1
)
);
// Option 4: Find specific match using Contains with check for required headers
err_List = {};
For ( e = 1, e <= Nitems( rqd_hdrs ), e++,
If( Contains( txtfile, rqd_hdrs[e] ) == 0,
errnum_desc = Concat("Error ", char( e ), ": ", "A required header ", rqd_hdrs[e], " is missing");
Insert Into( err_List, errnum_desc);
errhdrnum = 0;
Break();
,
errhdrnum = 1
)
);
);
Sample.DIF file用於開發和測試加載項。
sample.dif文件的內容顯示在附加圖像中,其中包含所需的標頭。
File Contents of sample.difsample.dif的文件內容
該插件的靈感來自於社區帖子 @JensRiege 當他問怎麼樣的時候在JMP腳本中導入.dif文件格式 。
鼓勵提出問題或意見。
乾杯,
斯坦
6星!(滿分5分)
我每天使用這種舊的文件格式,因為我們有一些傳統的軟件系統。
工作得非常好!
謝謝 !!!
-Jens