尝试编写脚本,将回归分析的结果附加到现有的 Excel 电子表格中您好 - 我正在尝试编写一个 jsl 脚本,将回归分析的结果附加到现有的 excel 文件中。我当前的脚本写入 excel 文件,但我希望能够多次运行该脚本并将每个新结果附加到现有的 excel 表中。(目前我正在手动附加新结果。)请参阅附加脚本。
提前致谢!
我正在使用 JMP Pro 17
自动化和脚本回复:尝试编写脚本,将回归分析结果附加到现有的 Excel 电子表格中非常好 — 谢谢你,吉姆!
回复:尝试编写脚本,将回归分析结果附加到现有的 Excel 电子表格中下面是一个示例脚本,我希望它能让你明白如何将新数据连接到主文件
names default to here(1);
// Create 2 data tables and save them as excel files
// one will be the master and one will play the role of the new data
dtExample = open("$SAMPLE_DATA/big class.jmp");
theTables =dtExample << Subset(
By( :sex ),
All rows,
Selected columns only( 0 ),
columns( :name, :age, :height, :weight )
);
close( dtExample, nosave );
// Change the names of the first table to Master
theTables[1] << set name("Master");
data table("Master") << bring window to front;
// Add the new columns to the master, like your master file already
// has all of the columns. In this example, I will only add 1 column
data table("Master")<< new column("Ratio", set each value(:height/:weight));
// Wait 5 seconds so you can observe the master table
wait(5);
// save and close the Master table as an excel table
close( data table("Master"), save("$TEMP/master.xlsx"));
// Change the name of the second table to New Data
theTables[2] << set name("New Data");
data table("New Data") << bring to front;
// wait 5 seconds here too, so you can observe the New Data table
wait(5);
// now save and close the New Data table as an excel table
close( data table("New Data"), save("$TEMP/New Data.xlsx"));
// Now that there are a Master and a New Data table that have been
// created we can now illustrate how to read in some new data,
// add the required new columns, save it, then open the master file,
// and concatenate the new data to the master and then save the updated
// master file
// open the new data table. I am using the variable dt as the pointer
// to the file, since that is what you are doing in your script
dt = open("$TEMP/New Data.xlsx");
// Add the new columns (in this example, only 1 column) to the data table
// your syntax is
// new column("ratio", formula(:height/:weight);
// I suggest that you become more precise and point to the specific data table
// by using either
// dt << New Column(......);
// or
// data table("New Data") << New Column( ...... );
data table("New Data") << New Column( "Ratio", formula(:height/:weight));
// Now the data can be saved
// use either
// dt<< save(...........);
// or
// data table("New Data")<< save(................);
dt << save("$TEMP\test1 n=22.xlsx");
// now open the master table
dtMaster = open("$TEMP\master.xlsx");
// concatenate the new data table to the master
dtMaster << concatenate( dt, append to first table(1));
// now save the master
dtMaster << save("$TEMP\master.xlsx");
// uncomment the below code if you want to close the new data and the master tables
// close( dt, nosave );
// close( dtMaster, nosave );
回复:尝试编写脚本,将回归分析结果附加到现有的 Excel 电子表格中不幸的是,这没有帮助。连接脚本仍然不起作用。(好奇的是,如果脚本自动执行该过程,我不确定为什么每次运行脚本时都需要单击弹出窗口上的复选框。)
此外(可能与连接脚本不起作用无关),出于某种原因,在运行开始时打开了一个残余文件(现已删除的文件),而不是脚本要求运行的文件。我不明白为什么会发生这种情况。

然后我运行回归,根据运行结果添加一些列,然后......

回复:尝试编写脚本,将回归分析结果附加到现有的 Excel 电子表格中尝试选中标有“附加到第一个表”的复选框
回复:尝试编写脚本,将回归分析结果附加到现有的 Excel 电子表格中这是运行后打开的内容。(奇怪的是,它显示了一个遗留文件名(v2n=25....),而我的 jsl 代码并没有使用它 - 我已经检查了一遍又一遍)。无论如何,以下代码(如下所示)不会生成连接的行。

dt << save("C:\Users\trcampbell\Desktop\MASTER ECOLI\2024\regression analysis\validation runs\testtest2 n=258.xls");
///添加附加脚本
连接(“C:\Users\trcampbell\Desktop\MASTER ECOLI\2024\regression analysis\validation runs\masterfile n=258.xls”);
//保存包含所有运行行(附加)的主文件
dt<< save("C:\Users\trcampbell\Desktop\MASTER ECOLI\2024\regression analysis\validation runs\masterfile n=258.xls");
如有任何建议,我们将不胜感激。
回复:尝试编写脚本,将回归分析结果附加到现有的 Excel 电子表格中是的
回复:尝试编写脚本,将回归分析结果附加到现有的 Excel 电子表格中谢谢 Jim。如果运行分析并添加表格的脚本生成了一个名为 X 的文件,那么在连接之前是否必须先保存 X?如果是这样,那么我的 Concatenate 函数中的表格名称是否是接收所有运行结果的文件(即 Concatenate (masterfile)?
因此,如果上述说法正确,我会说:
保存X
连接(主文件)
保存主文件
重新运行脚本
我理解得正确吗?
回复:尝试编写脚本,将回归分析结果附加到现有的 Excel 电子表格中看起来您需要做的是,在数据表中创建新列后,您需要读取要向其中添加数据的 Excel 表,使用 Tables=>Concatenate 将新表添加到要向其中添加数据的表中,然后保存新连接的表。