此加载项将从数据交换格式或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