JMP 社区您好,
这是我第一次发帖,也是我的第一个大型 JMP 脚本项目,所以请耐心等待。这个论坛对我目前的进展非常有帮助。
目标:拥有一个 JMP 仪表板,可打开并解析位于显示每个资产编号的 IR 图表的目录中的所有 Excel 文件。 实时是指每次打开仪表板/脚本时,它都会运行并更新图表。
限制条件:无法更改 Excel 报告的布局。
以下是我独立工作的代码片段。 当我把所有这些放在一起时,JMP 崩溃了。
我可能会错误地处理这一切。 打开每个文件并将列附加到新数据表可能会更容易。 根据它可以生成 X 个图表的列数。
任何帮助将不胜感激。
使用参考线创建控制图的代码。 想要从附加的电子表格中提取参考线的值力量要求字段和标题来自资产编号场地。
查看更多... 打开目录中所有文件的代码,但文件或数据需要有标题行 1 和数据起始行 2 才能工作。
查看更多...dirpath = Pick Directory();
TheFileList = Files In Directory( dirpath );
For( i = 1, i < 100, i++,
dt = Open( "F:\IPC\IPC PULL TEST RECORD LOGS\" || TheFileList[i], worksheet( "Sheet1" ) );
dt << Control Chart(
Sample Label( :Date ),
Group Size( 1 ),
KSigma( 3 ),
Chart Col( :Pull Force Reading, Individual Measurement ),
SendToReport(
Dispatch(
{"Individual Measurement of Pull Force Reading"},
"2",
ScaleBox,
{Min( 5 ), Max( 18 ), Inc( 2 ), Minor Ticks( 1 ), Add Ref Line( 8, "Solid", "Black", "LSL", 4 )}
),
Dispatch(
{"Individual Measurement of Pull Force Reading"},
"1",
ScaleBox,
{Min( 0 ), Max( 50 ), Inc( 8 ), Minor Ticks( 0 )}
),
Dispatch( {"Individual Measurement of Pull Force Reading"}, "IR Chart of IM", FrameBox, {Frame Size( 820, 420 )} ),
Dispatch( {"Individual Measurement of Pull Force Reading"}, "IR Chart of IM", FrameBox( 2 ), {Frame Size( 65, 405 )} )
)
);
);dirpath = 选择目录(); TheFileList = 目录中的文件( dirpath ); For( i = 1, i < 100, i++, dt = Open( "F:\IPC\IPC 拉力测试记录日志\" || TheFileList[i], worksheet( "Sheet1" ) ); dt << 控制图(样本标签( :日期 )、组大小( 1 )、KSigma( 3 )、图表 Col( :拉力读数、单独测量 )、SendToReport( Dispatch( {"单独测量拉力读数"}, "2", ScaleBox , {Min( 5 ), Max( 18 ), Inc( 2 ), 小刻度( 1 ), 添加参考线( 8, "Solid", "Black", "LSL", 4 )} ), Dispatch( {"拉力读数的单独测量"}, "1", ScaleBox, {Min( 0 ), Max( 50 ), Inc( 8 ), Minor Ticks( 0 )} ), Dispatch( {"拉力读数的单独测量" }, "IM 红外图", FrameBox, {帧尺寸( 820, 420 )} ), Dispatch( {"拉力读数的单独测量"}, "IM 红外图", FrameBox( 2 ), {帧尺寸( 65, 405 )} ) ) ); );
通过重新排列标题和数据来格式化一个文件的代码。
查看更多...dt = Open("F:\IPC\IPC PULL TEST RECORD LOGS\Asset# 3042.xlsx", worksheets("sheet1"));
dt << Delete rows (1::13);
var = dt:column 11[2];
dt:column 11[8] = var; //data
var = dt:column 11[1];
dt:column 11[7] = var; //heading
var = dt:column 3[1];
dt:column 12[7] = var; //heading
var = dt:column 3[2];
dt:column 12 [8] = var; //asset #
dt << delete rows (1::6);
dt << delete columns(1,3,5,7,9,13::25);
colNames = dt << get column names;
For( i = 1, i <= N Items( colNames ), i++,
Column( i ) << set name( Column( i )[1] )
);
dt << delete rows(1);dt = Open("F:\IPC\IPC 拉力测试记录日志\Asset# 3042.xlsx", worksheets("sheet1")); dt << 删除行 (1::13); var = dt:第 11 列[2]; dt:第 11 列[8] = var; //数据var = dt:第11列[1]; dt:第 11[7] 列 = var; //标题 var = dt:第 3 列[1]; dt:第 12 列[7] = var; //标题 var = dt:第 3 列[2]; dt:第 12 列 [8] = var; //资产 # dt << 删除行 (1::6); dt << 删除列(1,3,5,7,9,13::25); colNames = dt << 获取列名称; For( i = 1, i <= N Items( colNames ), i++, Column( i ) << 集合名称( Column( i )[1] ) ); dt << 删除行(1);
吉姆,
在我的研究和故障排除过程中,我看到您对许多讨论做出了贡献。 我真的很荣幸您能在这里参与我的讨论。
起初我在运行脚本时遇到了一些问题。 查看日志和调试器后,我发现它在某个文件上停止。 下一个文件是我采用不同格式的测试文件。 我删除了该文件,没有更改脚本,它工作得很好。 后来我在运行脚本时打开了一个文件,并收到另一个错误,但这是一个简单的修复(关闭文件)。
我打算了解您的全部代码,但我还有一些进一步的自定义,希望您也能提供帮助:
- 可以将 LSL 值添加到图表中,甚至移动到与 UCL/LCL 相同的一侧(右侧)吗?
- 某些数据集的 LSL 超过 50。 这不适合当前图表,因此我将范围修改为 1 - 100。 有没有办法满足拉力要求并将其用于+/- 10或20的范围?
- 有些 Excel 工作表是空的。 有没有办法省略图表?
编辑:我今天花了一些时间来添加上面的自定义内容,这是上面的修改后的代码。 看起来更改参考标签相当困难。 我发现的唯一提示是创建一个新的文本框并使用该代码,但不确定如何链接参考线的 Y 高度。
Names Default To Here( 1 );
// Delete the old Dashboard
Try( NW << close window );
dirpath = Pick Directory();
TheFileList = Files In Directory( dirpath );
// Create the Dashboard window to place the charts into
NW = New Window( "Asset Dashboard", <<JOURNAL>col=Column( Current Data Table(), "Pull Force Reading");
tableVal = col[22];
if (tableVal == "", i++);
// Capture the Force Requirement value and add it to the graph if it is valid
dt:Pull Force Reading << data type( numeric ) << modeling type( continuous );
theForceRequirement = Num( Word( 1, dt:Force Requirement[1], " " ) );
If( Is Missing( theForceRequirement ) == 0,
<STRONG>range = theForceRequirement;</STRONG>
theForceRequirement = ",Add Ref Line(" || Char( theForceRequirement ) || ", \!"Dashed\!", \!"Black\!", \!"LSL\!", 4 )";,
theForceRequirement = " "
);
// Capture the Asset number
If( dt:Name( "Asset#" )[1] == "",
theAsset = "Unknown",
theAsset = dt:Name( "Asset#" )[1]
);
// Generate the code to produce the chart along with the LSL value
theExpr =
"cc = Control Chart(invisible,
Sample Label( :Date ),
Group Size( 2 ),
KSigma( 3 ),
Chart Col( :Pull Force Reading, Individual Measurement(Show Zones( 1 ), Shade Zones( 1 ),Test 1( 1 ), Test 3( 1 ))),
SendToReport(
Dispatch(
{\!"Individual Measurement of Pull Force Reading\!"},
\!"2\!",
ScaleBox,
{Min( <STRONG>if( (range - 20) <= 0 , 0, range - 20)</STRONG> ), Max( <STRONG>range + 20</STRONG> ), Inc( 2 ), Minor Ticks( 1 )"
|| theForceRequirement ||
" }
),
Dispatch(
{\!"Individual Measurement of Pull Force Reading\!"},
\!"1\!",
ScaleBox,
{Min( 0 ), Max( 50 ), Inc( 8 ), Minor Ticks( 0 )}
),
Dispatch(
{\!"Individual Measurement of Pull Force Reading\!"},
\!"IR Chart of IM\!",
FrameBox,
{Frame Size( 820, 420 )}
),
Dispatch(
{\!"Individual Measurement of Pull Force Reading\!"},
\!"IR Chart of IM\!",
FrameBox( 2 ),
{Frame Size( 65, 405 )}
)
)
);";
// Run the generated code
Eval( Parse( theExpr ) );
// Close the outline box of the output and set the title based upon the asset value
Report( cc )[Outline Box( 1 )] << Close( 1 ) << set title( "Asset# " || theAsset );
// Append the display output to the display window
VLB << Append( Report( cc ) );
// Clean up the environment by closing the display window and the data table
//cc << close window;
//Close( dt, nosave );
); // End of For Loop</JOURNAL>
我认为这很接近你想要的。它可能需要一些调整,但至少它应该为您提供一个良好的开始,了解如何将这一切组合在一起
Names Default To Here( 1 );
// Delete the old Dashboard
Try( NW << close window );
dirpath = Pick Directory();
TheFileList = Files In Directory( dirpath );
// Create the Dashboard window to place the charts into
NW = New Window( "Asset Dashboard", <<JOURNAL></JOURNAL>