Concatenate all data tables using JSLHi, I want to concatenate all open data tables. However, the number of data tables can vary and I want the script to be able to adapt for different number of tables.
This is the code for what I want to do, however I want to have it generalised:
Data Table( N Table() ) << Concatenate(
Data Table( (N Table()-1) ),
Data Table( (N Table()-2) ),
Data Table( (N Table()-3) ),
Data Table( (N Table()-4) ),
Data Table( (N Table()-5) ),
Output Table( "All Temps" ),
Create source column
);
This is code I have tried, an error of unresolved name of output table occurs ( in this case noTemps is 6 )
Data Table( N Table() ) << Concatenate(
For( i = 1, i < (noTemps), i++,
Data Table( (N Table()-i) ),
);
Output Table( "All Temps" ),
Create source column
);
Automation and ScriptingData AccessData Blending and CleanupRe: Concatenate all data tables using JSLWhich version of JMP are you using?
Re: Concatenate all data tables using JSLIf JMP16+ I would use for each and loop over the list of tables
Names Default To Here(1);
dt1 = Open("$SAMPLE_DATA/Big Class.jmp");
dt2 = dt1 << Subset(All Rows, Selected Columns(0), Output Table("DEMO"));
dts = Get Data Table List();
dt_first = Remove From(dts, 1); // remove first table as we concatenate to that
For Each({dt}, dts,
dt_first << Concatenate(
dt,
"Append to first table",
"Create source column"
);
// Close(dt, no save);
);Re: Concatenate all data tables using JSLThank you for your response, however I'm struggling to make this apply to my situation (although I think it should be relatively easy).
What is dt? I get a name unresolved error.
I also don't have dt1 assigned as all the tables are already open from the previous part of the script. How can I assign it without directly calling a specific table?
If I do assign dt1 like below a demo table is produced however, the table is full of the word demo.
dt1 = Open( "$DOCUMENTS/Plot_Conduction_Losses/Module 6/DUT2/100C.jmp" );
Sorry if this is poorly explained and wordy.
Re: Concatenate all data tables using JSLdt1 and dt2 are there just for demonstration purposes. You get the references to all open tables using Get Data Table List(). Which JMP version are you using (For each requires JMP16+, but it can be replaced with For)? dt is reference to a data table which can be found from the list of datatable referenes in dts.
Re: Concatenate all data tables using JSLI have JMP 17.
I understand the dt part now, sorry for the confusion.
dts = Get Data Table List();
dt_first = Remove From(dts, 1); // remove first table as we concatenate to that
For Each({dt}, dts,
dt_first << Concatenate(
dt,
//Append to first table,
"Create source column",
Output Table( "All Temps" ),
);
//Close(dt, no save);
);
This isn't quite what I want. It produces 6 new data tables all concatenated with dt_first. I would like it to be a new data table. If I uncomment append to first table line. it produces 6 source columns which I am unable to use to sort by in further anaylsis.
Re: Concatenate all data tables using JSLDidn't remember you can use a list with concatenate
Names Default To Here(1);
Open("$SAMPLE_DATA/Students.jmp");
Open("$SAMPLE_DATA/Students1.jmp");
Open("$SAMPLE_DATA/Students2.jmp");
dts = Get Data Table List();
dt_first = Remove From(dts, 1)[1]; // remove first table as we concatenate to that
dt_result = dt_first << Concatenate(dts, "Create source column");
Also have to/should get first index from Remove From() because Remove From() returns a lists.