如何使用腳本將子集儲存到單獨的資料夾我建立了一個腳本,該腳本將匯入 Excel 檔案並執行分析,產生 3 個子集。 每個子集需要是不同的資料夾,但我希望子集與匯入以建立子集的 Excel 檔案具有相同的名稱。 我將如何做到這一點,或者至少為每個子集命名一個特定的名稱並將它們保存到不同的資料夾中。
內容組織視窗回覆:如何使用腳本將子集儲存到單獨的資料夾太感謝了! 這非常有幫助
回覆:如何使用腳本將子集儲存到單獨的資料夾另外@tx尼爾森的廣泛答案,你可能想看看這個函數轉換檔案路徑。雖然,顧名思義,它可以用於轉換檔案路徑(例如從 Windows 格式到 MacOS 格式,或從相對路徑到完整路徑),但我喜歡它,因為它允許我操作檔案路徑,同時將檔案名稱和目錄資訊分開,而不必擔心字串連接。
例如
projectHomeFolder = FilePathDefinitions:getProjectHome();
path = convertFilePath("Master_Table.jmp",base(projectHomeFolder));回覆:如何使用腳本將子集儲存到單獨的資料夾這是執行此操作的一種方法的範例
// Open a file and create 2 subsets and then save all 3 files to
// different folders, keeping the files open in the JMP session,
// and with their original name, but naming each subset in their
// folders where they are saved
Names Default To Here( 1 );
// open the Big Class data table.
dt = Open( "$SAMPLE_DATA/big class.jmp" );
// Create subset one with all Males, letting JMP provide the new data table name
dt << select where( :sex == "M" );
dtA = dt << subset( selected columns( 0 ), selected rows( 1 ) );
// Create subset two with all Females, giving JMP the name of the new table
dt << select where( :sex == "F" );
dtB = dt << subset( selected columns( 0 ), selected rows( 1 ), Output Table( "All Females" ) );
// The Save() function automatically changes the name of the data table being saved
// to the name being specified in the file name specified in the Path of the Save()
// function. Therefore to keep the original table the original name, it has to be
// renamed back to the original name.
holdName = dt << get name;
dt << save( "C:/folderA/MyName.jmp" );
dt << set name( holdName );
// Repeat the save for the first subset
holdName = dtA << get name;
dtA << save( "C:/folderB/MyName.jmp" );
dtA << set name( holdName );
// Repeat for the second subset. The name of this subset has been specifically provided
// so the handling of this can be a little different
Data Table( "All Females" ) << save( "C:/folderC/MyName.jmp" );
Data Table( "MyName" ) << set name( "All Females" );