- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Concatenate a list of Tables and add a "Source Column"
I Have a list of open tables (names) that I want to concatenate and add a new “Source Column” that can be retrieved from the same list of table names. I have tried all the previous “solutions: published on this Discussion board without luck (only partial luck)
I can get my concatenated tables following a solution published by TXNelson, but I cannot seem to be able to get the “Source Column” to work. I will appreciate any help solving this one.
tables = {"R1", "R2", "R3"};
TablesN ={};
For(k = 1, k <= n Rows ( Data Table(tables[i] )),k++,
Insert Into(TablesN, Data Table (tables [i] ) << get name));
// the concatenation works like a charm
Data Table = New Table ("RST");
For( i = 1, i <= N Items( tables ), i++,
Data Table( "RST" ) << Concatenate(
Data Table( tables[i] ),
append to first table(1)
);
//Close( Data Table( tables[i] ), No Save );
);
// this part fails
data table( "RST" ) << add multiple columns("Source Table", 1, before first, character );
:Source Table << set values( TablesN );
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Concatenate a list of Tables and add a "Source Column"
The last part should work if the list has any values. Check out the first for loop; it uses k as iterator but inside the loop i, not defined, is used as list index.
A source column can also be created automatically with Concatenate() as in the example below.
// Create a list of data tables
names = {"R1", "R2", "R3"};
tables = {};
For( i = 1, i <= N Items( names ), i++,
Insert Into( tables, Data Table( names[i] ) )
);
// Concat all and create a source column in one step
dt = New Table( "RST" );
dt << concatenate( tables, append to first table( 1 ), create source column( 1 ) );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Concatenate a list of Tables and add a "Source Column"
The last part should work if the list has any values. Check out the first for loop; it uses k as iterator but inside the loop i, not defined, is used as list index.
A source column can also be created automatically with Concatenate() as in the example below.
// Create a list of data tables
names = {"R1", "R2", "R3"};
tables = {};
For( i = 1, i <= N Items( names ), i++,
Insert Into( tables, Data Table( names[i] ) )
);
// Concat all and create a source column in one step
dt = New Table( "RST" );
dt << concatenate( tables, append to first table( 1 ), create source column( 1 ) );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Concatenate a list of Tables and add a "Source Column"
Hi MS,
I tested your code:
dt = New Table( "RST" );
dt << concatenate( tables, append to first table( 1 ), create source column( 1 ) );
and it creates a pop up window that would allow me to select the tables to concatenate, which defeats the purpose of creating a script to automate the process. It does not iterate through the "tables" list. I am using JMP 15 .
Just FYI, this is the post that I have been using to guide me. Thanks.
https://community.jmp.com/t5/Discussions/JSL-bug-Concatenate-all-opened-table-into-1-table-and-close...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Concatenate a list of Tables and add a "Source Column"
The list tables must contain data table objects (first part of my code illustrate one way do create such a list) and all tables must still be open when the code is run. Otherwise you'll get the pop-ip window.
After the code is run, you can close all (saved) data tables in the list in one step with tables << close window;.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Concatenate a list of Tables and add a "Source Column"
Best regards,
Alfredo