JSL腳本將列轉置為行我不確定如何開始,我想要一個腳本的幫助,該腳本會自動將特定選擇的列轉置為行。
我知道如何手動執行此操作,但我需要一個腳本,因為這是數百個數據文件的非常重複的任務
請參閱附件的jmp文件以獲取數據示例和所需結果
我將衷心感謝您的幫助
數據表腳本編寫回复:JSL腳本將列轉置為行以下腳本是創建所需輸出表的良好起點
Names Default To Here( 1 );
dt = Current Data Table();
// Transpose the Demographics
dtTrans1 = dt << Transpose(
columns( :SBIN, :HBIN, :Alarms, :Device, :Site ),
Transpose selected rows only( 1 ),
Output Table( "Transpose 1" )
);
// Change the name of the first column
dtTrans1:Label << set name( "Column 1" ) << Set Display Width( 150 );
// Change the new column names
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i ) << set name( "Column " || Char( i + 4 ) ) << Set Display Width( 100 )
);
// Change the detail name of the Alarms
dtTrans1:Column 1[(dtTrans1 << get rows where( dtTrans1:Column 1 == "Alarms" ))[1]] = "Pass/Fail/Alarm";
// Create the Devce values
deviceRow = (dtTrans1 << get rows where( dtTrans1:Column 1 == "Device" ))[1];
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i )[deviceRow] = i - 1
);
// Now Find all of the columns that are parameters
parameterColNamesList = {};
For( i = 1, i <= N Cols( dt ), i++,
If( Is Missing( Num( Word( 1, Column( dt, i ) << get name, ":" ) ) ) == 0,
Insert Into( parameterColNamesList, Column( dt, i ) << get name )
)
);
// Transpose the parameter columns
dtTrans2 = dt << Transpose(
columns( Eval( parameterColNamesList ) ),
Transpose selected rows only( 0 ),
Output Table( "Transpose 2" )
);
// Add in the new columns to be created
dtTrans2 << Add Multiple Columns( "Column", 5, before first, Character );
// Add the values to the new columns
For( i = 1, i <= N Rows( dtTrans2 ), i++,
dtTrans2:Column 1[i] = Word( 1, dtTrans2:Label[i], ":" );
dtTrans2:Column 2[i] = Word( 2, dtTrans2:Label[i], ":" );
specs = Column( dt, dtTrans2:Label[i] ) << get property( "spec limits" );
If( Is Missing( specs["LSL"] ) == 0,
dtTrans2:Column 3[i] = specs["LSL"]
);
If( Is Missing( specs["USL"] ) == 0,
dtTrans2:Column 4[i] = specs["USL"]
);
If( Column( dt, dtTrans2:Label[i] ) << get property( "Units" ) != "",
dtTrans2:Column 5[i] = Column( dt, dtTrans2:Label[i] ) << get property( "Units" )
);
);
// Get rid of the label column which is no longer needed
dtTrans2 << delete columns( :Label );
// Change the names of the Trans2 table to match the names in the Trans1 table
For( i = 6, i <= N Cols( dtTrans2 ), i++,
Column( dtTrans2, i ) << set name( "Column " || Char( i ) )
);
// Combine the 2 Transformed data tables
dtFinal = dtTrans1 << concatenate( dtTrans2 );
// Cleanup the no longer needed data tables
close( dtTrans1, nosave );
close( dtTrans2, nosave );回复:JSL腳本將列轉置為行謝謝!這似乎很好。 但是由於某種原因,測試名稱Lo Limit和Hi Limit列放在最後。有什麼辦法可以重新排列它們並在腳本中標記它們?

回复:JSL腳本將列轉置為行您正在使用什麼版本的JMP?回复:JSL腳本將列轉置為行我正在使用jmp 14
回复:JSL腳本將列轉置為行這是腳本的更正版本,它將規範列等放置在正確的位置,並且還添加了列標籤
Names Default To Here( 1 );
dt = Current Data Table();
// Transpose the Demographics
dtTrans1 = dt << Transpose(
columns( :SBIN, :HBIN, :Alarms, :Device, :Site ),
Transpose selected rows only( 1 ),
Output Table( "Transpose 1" )
);
// Change the name of the first column
dtTrans1:Label << set name( "Column 1" ) << Set Display Width( 150 );
// Change the new column names
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i ) << set name( "Column " || Char( i + 4 ) ) << Set Display Width( 100 )
);
// Change the detail name of the Alarms
dtTrans1:Column 1[(dtTrans1 << get rows where( dtTrans1:Column 1 == "Alarms" ))[1]] = "Pass/Fail/Alarm";
// Create the Devce values
deviceRow = (dtTrans1 << get rows where( dtTrans1:Column 1 == "Device" ))[1];
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i )[deviceRow] = i - 1
);
// Now Find all of the columns that are parameters
parameterColNamesList = {};
For( i = 1, i <= N Cols( dt ), i++,
If( Is Missing( Num( Word( 1, Column( dt, i ) << get name, ":" ) ) ) == 0,
Insert Into( parameterColNamesList, Column( dt, i ) << get name )
)
);
// Transpose the parameter columns
dtTrans2 = dt << Transpose(
columns( Eval( parameterColNamesList ) ),
Transpose selected rows only( 0 ),
Output Table( "Transpose 2" )
);
// Add in the new columns to be created
dtTrans2 << Add Multiple Columns( "Column", 5, before first, Character );
// Add the columns 2-5 in the trans data table
dtTrans1 << Add Multiple Columns( "xColumn", 4,after(:Column 1), Character );
for(i=2,i<=5,i++,
column(dtTrans1,i)<<SET name=""></SET>回复:JSL腳本將列轉置為行謝謝吉姆!格式完美。但是由於某種原因,它不能與其他類似的數據集一起使用。有什麼原因嗎?
回复:JSL腳本將列轉置為行日誌中是否有任何錯誤消息?
2個數據表之間有什麼區別?
腳本在完成之前就停止了嗎?
回复:JSL腳本將列轉置為行沒有日誌錯誤。當我運行腳本時,它什麼都不做。唯一的區別是測試名稱...它們是不同的。但所有其他標頭都相同回复:JSL腳本將列轉置為行嘗試運行第1行到第26行的代碼。您要做的就是選擇(突出顯示)腳本中的那些行,然後單擊“運行”圖標。
Names Default To Here( 1 );
dt = Current Data Table();
// Transpose the Demographics
dtTrans1 = dt << Transpose(
columns( :SBIN, :HBIN, :Alarms, :Device, :Site ),
Transpose selected rows only( 1 ),
Output Table( "Transpose 1" )
);
// Change the name of the first column
dtTrans1:Label << set name( "Column 1" ) << Set Display Width( 150 );
// Change the new column names
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i ) << set name( "Column " || Char( i + 4 ) ) << Set Display Width( 100 )
);
// Change the detail name of the Alarms
dtTrans1:Column 1[(dtTrans1 << get rows where( dtTrans1:Column 1 == "Alarms" ))[1]] = "Pass/Fail/Alarm";
// Create the Devce values
deviceRow = (dtTrans1 << get rows where( dtTrans1:Column 1 == "Device" ))[1];
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i )[deviceRow] = i - 1
);
查看“轉置1”數據表是否如下所示:

30-35行
parameterColNamesList = {};
For( i = 1, i <= N Cols( dt ), i++,
If( Is Missing( Num( Word( 1, Column( dt, i ) << get name, ":" ) ) ) == 0,
Insert Into( parameterColNamesList, Column( dt, i ) << get name )
)
);
並查看parameterColNamesList是否包含數據表中所有測試的名稱。
然後繼續檢查代碼的不同部分,直到找到運行不正常的地方。
如果您可以向我提供您要讀取的數據表的副本,我將願意自己進行檢查。
回复:JSL腳本將列轉置為行確定在這裡
回复:JSL腳本將列轉置為行這是一個隨機樣本數據
回复:JSL腳本將列轉置為行忽略先前的樣本,請使用此樣本
回复:JSL腳本將列轉置為行這是一個
回复:JSL腳本將列轉置為行問題是輸入了一個或多個參數作為字符數據。轉置不能處理混合數據。因此,我添加了一項檢查以確保所有檢測到的參數都是數字。
Names Default To Here( 1 );
dt = Current Data Table();
// Transpose the Demographics
dtTrans1 = dt << Transpose(
columns( :SBIN, :HBIN, :Alarms, :Device, :Site ),
Transpose selected rows only( 1 ),
Output Table( "Transpose 1" )
);
// Change the name of the first column
dtTrans1:Label << set name( "Column 1" ) << Set Display Width( 150 );
// Change the new column names
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i ) << set name( "Column " || Char( i + 4 ) ) << Set Display Width( 100 )
);
// Change the detail name of the Alarms
dtTrans1:Column 1[(dtTrans1 << get rows where( dtTrans1:Column 1 == "Alarms" ))[1]] = "Pass/Fail/Alarm";
// Create the Devce values
deviceRow = (dtTrans1 << get rows where( dtTrans1:Column 1 == "Device" ))[1];
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i )[deviceRow] = i - 1
);
// Now Find all of the columns that are parameters
parameterColNamesList = {};
For( i = 1, i <= N Cols( dt ), i++,
If( Is Missing( Num( Word( 1, Column( dt, i ) << get name, ":" ) ) ) == 0,
Insert Into( parameterColNamesList, Column( dt, i ) << get name )
)
);
// Transpose the parameter columns
dtTrans2 = dt << Transpose(
columns( Eval( parameterColNamesList ) ),
Transpose selected rows only( 0 ),
Output Table( "Transpose 2" )
);
// Add in the new columns to be created
dtTrans2 << Add Multiple Columns( "Column", 5, before first, Character );
// Add the columns 2-5 in the trans data table
dtTrans1 << Add Multiple Columns( "xColumn", 4,after(:Column 1), Character );
for(i=2,i<=5,i++,
column(dtTrans1,i)<<SET name=""></SET>回复:JSL腳本將列轉置為行謝謝吉姆,但由於某些原因我仍然與更新的腳本有相同的錯誤

回复:JSL腳本將列轉置為行我的錯誤....由於錯誤,我發送給您的最後一個條目沒有我的修改。 我已經編輯了我的最新回复並更新了JSL。 請返回並拉出JSL並運行它。 現在,它包含更正的代碼。回复:將列轉置為行的 JSL 腳本謝謝吉姆