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>