如何使用脚本将子集保存到单独的文件夹我创建了一个脚本,它将导入和 excel 文件并执行将生成 3 个子集的分析。 每个子集都需要是不同的文件夹,但我希望子集与为创建子集而导入的 excel 文件具有相同的名称。 我该怎么做,或者至少为每个子集命名一个特定的名称并将它们保存到不同的文件夹中。
脚本视窗回复:如何使用脚本将子集保存到单独的文件夹这是执行此操作的一种方法的示例
// 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" );
回复:如何使用脚本将子集保存到单独的文件夹此外@txnelson的广泛回答,你可能想看看这个功能转换文件路径.尽管顾名思义,它可用于转换文件路径(例如从 Windows 格式到 MacOS 格式,或从相对路径到完整路径),但我喜欢它,因为它允许我在将文件名和目录信息分开的同时操作文件路径,而不必担心字符串连接。
例如
projectHomeFolder = FilePathDefinitions:getProjectHome();
path = convertFilePath("Master_Table.jmp",base(projectHomeFolder));回复:如何使用脚本将子集保存到单独的文件夹太感谢了! 这非常有帮助