Re: How do I apply a script to multiple data tables at a time? (JMP 17)Using For Each is the correct idea. You get the reference to your reference data table when you open it and you get a list of references to other datatables from Multiple File Import (if I remember correctly...). You can then loop over that list by using For Each
Re: How do I apply a script to multiple data tables at a time? (JMP 17)Hello @Kast,
A follow-up to what @jthi mentioned. A script to do this might look like this. The correct expression syntax is still a bit fuzzy to me, but this should be most of the way to what you need.
Names default to here(1);
dt_list = Multiple file import(); // Incomplete placeholder
table_script = expr( New script( "Table script name here", // Add new tables scripts with New script()
Graph Builder( // Incomplete table script graphic script
Size( 800, 800 ),
Show Control Panel( 0 ),
Variables( X( :Column 1 ) ),
Elements( Points( X, Y, Legend( 5 ) ) ),
SendToReport(
Dispatch(
{},
"graph title",
TextEditBox,
{Set Text( "Example title" )}
)
)
)
);
Eval( // For each loop adds table_script to each data table named in dt_list
Eval Expr(
For Each( {value, index},
Expr( dt_list[index] << table_script )
)
)
);
Eval( // for loop alternative
eval expr(
for( i = 1, i <= N Items( dt_list ), i++,
expr( dt_list[i] << table_script )
)
)
);How do I apply a script to multiple data tables at a time? (JMP 17)I'm looking for a way to execute a script across multiple data tables by executing the script once as opposed to executing the script one time per data table.
Current Data Flow
- Open reference JMP data table.
- Use a 1st script (based on Multiple File Import) to import multiple excel files into multiple JMP data tables (1 Table Per File).
- Result: 1 Reference Data Table Open and 2-10+ new JMP Data Tables from import script.
- Run a 2nd script on each created JMP DataTable to clean up the data and update the created data tables with data from the reference JMP data table.
- Result: 1 Reference Data Table and 2-10+ JMP data tables that have been cleaned up (delete columns, add calculated columns, etc) and have been updated (scripted Update data table) with data from the reference data table.
I'd like to find a solution where I don't have to manually apply my 2nd script individually to each created JMP Data Table.
I'm open to any approaches.
I've thought about trying to use JMP lists and/or the "For Each" function but I haven't been able to find examples of applying these to data tables. I think I would need to make a list of all open data tables filtered by their name (so I can filter out the reference data table I use to update the data tables of interest), I also don't know how to do this.
Thank you for any and all advice and ideas.
Automation and ScriptingRe: How do I apply a script to multiple data tables at a time? (JMP 17)Thank you both. Really appreciate the help.
; //with all Multiple File Import details included
</CODE></PRE><P>definitely works for making the list.</P><P> </P><P>I wasn't able to get this to work for myself, but I'm still learning how to use Eval, EvalExpr, Expr, etc.</P><PRE><CODE class=" language-jsl">Eval( // For each loop adds table_script to each data table named in dt_list
Eval Expr(
For Each( {value, index},
Expr( dt_list[index] << table_script )
)
)
);dt_list = Multiple File Import()
I was able to get a simple test to work with For Each in this format. Simple added column script.
For Each({listitem}, dt_list, listitem << New Column( "Mean",
Numeric,
"Continuous",
Formula( Mean( :A, :B, :C, :D</img> ) ),
Format( "Best", 12 )));My complete working example code is
Names default to here(1);
dt_list = Multiple File Import(
<<SET folder=""> ) ),
Format( "Best", 12 )));
</SET>