將腳本應用於多個資料表我有一個腳本,在 JMP 中開啟一個 txt 檔案作為資料表,然後將第 7 行中列出的列名稱移至列標題。 如何將其應用於多個數據表? 我當前的腳本不起作用。 我有JMP16。 謝謝。
dt_list = Multiple File Import(); //additional known text here to open files
table_script = expr(
//Move the column names listed in row 7 to the column headers
dt = Current Data Table();
dt << clear select;
dt << Clear Column Selection();
lastcol = N Col( dt );
header = 7;
For( i = 1, i <= lastcol, i++,
Column( i ) << set Name( Column(i)[header] )
);
);
Eval(
Eval Expr(
For Each( {value, index},
Expr( dt_list[index] << table_script )
)
)
); 自動化和腳本編寫回覆:將腳本應用於多個資料表這是我的設定方法
Names Default To Here( 1 );
dt_list = Multiple File Import();
table_script = Function( {dt},
{defaultlocal},
//Move the column names listed in row 7 to the column headers
dt << clear select;
dt << Clear Column Selection();
lastcol = N Col( dt );
header = 7;
For( i = 1, i <= lastcol, i++,
Column( i ) << set Name( Column( i )[header] )
);
);
For Each( {value}, dt_list, table_script( value ) );回覆:將腳本應用於多個資料表感謝您的回覆! 我嘗試了您的腳本,但它僅在打開的最後一個資料表上執行 table_script 函數。 您知道可能出現什麼問題嗎? 謝謝。
回覆:將腳本應用於多個資料表我複製了您指出的發現,但無法使用我正在採取的方法來糾正該問題。所以我回到了你的原始程式碼,並簡化了方法並成功運行了一個完整的範例。
Names Default To Here( 1 );
rc = Create Directory( "$TEMP/sub1" );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
Close( dt, save( "$TEMP/sub1/MFI big class.jmp" ) );
dt = Open( "$SAMPLE_DATA/body fat.jmp" );
Close( dt, save( "$TEMP/sub1/MFI body fat.jmp" ) );
dt = Open( "$SAMPLE_DATA/candy bars.jmp" );
Close( dt, save( "$TEMP/sub1/MFI candy bars.jmp" ) );
Show( Files In Directory( "$TEMP/sub1" ) );
dt_list = Multiple File Import(
<<SET folder=""></SET>
回覆:將腳本應用於多個資料表太感謝了! 您的新腳本可以對所有開啟的資料表進行編輯。 但是,我發現我的腳本未按預期運行,而是將“7”附加到所有列標題,而不是將第 7 行移動為列標題。 它以前適用於單一資料表,但在這種情況下,我需要更改程式碼以實際讀取指定位置中的表值。 這是我的工作代碼:
Names Default To Here( 1 );
dt_list = Multiple File Import();
table_script = Expr(
//Move the column names listed in row 7 to the column headers
dt = Current Data Table();
dt << clear select;
dt << Clear Column Selection();
lastcol = N Col( dt );
header = 7;
For( i = 1, i <= lastcol, i++,
tableVal = Column( Current Data Table(), i)[ header ];
Column( i ) << set Name( tableVal )
);
);
For Each( {table}, dt_list,
Current Data Table( table );
table_script;
);