Tentativo di scrivere uno script che aggiunga i risultati dell'analisi di regressione a un foglio di calcolo Excel esistenteCiao, sto cercando di scrivere uno script jsl che aggiungerà i risultati di un'analisi di regressione a un file excel esistente. Il mio script attuale scrive su un file excel, ma voglio essere in grado di eseguire lo script più volte e aggiungere ogni nuovo risultato al foglio excel esistente. (Attualmente sto aggiungendo il nuovo risultato manualmente, a mano.) Vedere lo script allegato.
Grazie in anticipo!
ps Sto usando JMP Pro 17
Automazione e scriptingRe: Tentativo di scrivere uno script che aggiunga i risultati dell'analisi di regressione a un foglio di calcolo Excel esistenteOttimo, grazie, Jim!
Re: Tentativo di scrivere uno script che aggiunga i risultati dell'analisi di regressione a un foglio di calcolo Excel esistenteEcco uno script di esempio che spero chiarisca cosa è necessario fare per concatenare nuovi dati a un file master
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 );
Re: Tentativo di scrivere uno script che aggiunga i risultati dell'analisi di regressione a un foglio di calcolo Excel esistenteSfortunatamente, non è servito a niente. Lo script di concatenazione non funziona ancora. (Curioso, se lo script automatizza il processo, non so perché dovrei cliccare una casella di controllo su una finestra popup ogni volta che eseguo lo script.)
Inoltre (probabilmente non correlato al fatto che lo script di concatenazione non funziona), per qualche motivo un relict (ora file eliminato) viene aperto all'inizio dell'esecuzione, invece del file che lo script dice di eseguire. Non riesco a capire perché ciò accada.

Quindi eseguo la regressione, aggiungo alcune colonne in base ai risultati dell'esecuzione e poi...

Re: Tentativo di scrivere uno script che aggiunga i risultati dell'analisi di regressione a un foglio di calcolo Excel esistenteProva a selezionare la casella di controllo denominata "Aggiungi alla prima tabella"
Re: Tentativo di scrivere uno script che aggiunga i risultati dell'analisi di regressione a un foglio di calcolo Excel esistenteEcco cosa si apre dopo l'esecuzione. (Curiosamente, mostra un nome di file relict (v2n=25....) che il mio codice jsl NON usa - ho controllato e ricontrollato). In ogni caso, il codice seguente - mostrato di seguito - non produce righe concatenate.

dt << save("C:\Utenti\trcampbell\Desktop\MASTER ECOLI\2024\analisi di regressione\esecuzioni di convalida\testtest2 n=258.xls");
///AGGIUNGI SCRIPT DI APPENDICE
Concatenate("C:\Utenti\trcampbell\Desktop\MASTER ECOLI\2024\analisi di regressione\esecuzioni di convalida\masterfile n=258.xls") ;
//SALVA MASTERFILE CONTENENTE LE RIGHE (ALLEGATE) DI TUTTE LE ESECUZIONI
dt<< save("C:\Utenti\trcampbell\Desktop\MASTER ECOLI\2024\analisi di regressione\esecuzioni di convalida\masterfile n=258.xls");
Ogni suggerimento sarà molto apprezzato.
Re: Tentativo di scrivere uno script che aggiunga i risultati dell'analisi di regressione a un foglio di calcolo Excel esistenteSÌ
Re: Tentativo di scrivere uno script che aggiunga i risultati dell'analisi di regressione a un foglio di calcolo Excel esistenteGrazie Jim. Se lo script che esegue l'analisi e aggiunge tabelle produce un file denominato X, X deve essere prima salvato prima della concatenazione? E se sì, il nome della tabella all'interno della mia funzione Concatenate è il file che riceve i risultati di tutte le esecuzioni (ad esempio Concatenate (masterfile)?
Quindi, se quanto sopra è corretto, direi:
salva X
concatenare (masterfile)
salva file master
rieseguire lo script
Sto leggendo correttamente?
Re: Tentativo di scrivere uno script che aggiunga i risultati dell'analisi di regressione a un foglio di calcolo Excel esistenteSembra che ciò che devi fare è leggere la tabella Excel a cui vuoi aggiungere i dati, usare Tabelle=>Concatena per aggiungere la nuova tabella alla tabella a cui vuoi aggiungere i dati e quindi salvare la nuova tabella concatenata.