I have a script that opens multiple data tables and creates new columns in those data tables. Is it possible to script a column copier box that shows every columns from every data table opened? so I can select and copy the only columns I want with their properties?
My current code tries to concatenate the data tables into one new table before copying the columns but it looks like JMP would not let me concatenate more than two data tables at the same time.
Below is a summary of the code I wrote to make it easier to edit. Thanks.
Names Default To Here( 1 );
// Use 'PickFile()' to get a list of files to open (Windows only)
fileList = Pick File(
"Select one of more files", // Prompt
"$DESKTOP", // Initial folder
{"JMP Files|jmp;jsl;jrn;csv", "All Files|*"}, // List of file filters to apply (ignored by OS/X)
1, // Initial file filter to apply (index of item in the list above)
0, // Save flag - Specify either a 'Save' or 'Open' window. Set a value of 1 or 0 respectively.
Empty(), // Default file
multiple // Multiple - If 'Save Flag' = 0, using a value of 1 allows more than one file to be opened (ignored by OS/X)
);
// If only a single file is selected, fileList will not be a list, so we need to build it for ourselves
If( !Is List( fileList ),
fileList = Eval List( {fileList} )
);
// Open the files and store their corresponding JMP table names
tableNames = {};
For( f = 1, f <= N Items( fileList ), f++,
dt = Open( fileList[f] );
Insert Into( tableNames, dt << getName );
);
dt = New Table("Concatenated Dog H");
//Create Column Copier to copy files
dt = Current Data Table();
col_dlg = new window("Column Copier",
panelbox("Select four columns to create a new table with:",
col_clist = collistbox(all, width(200), max selected(4)),
),
buttonbox("OK",
selected_column_list = col_clist << getselected;
col1 = selected_column_list[1];
col2 = selected_column_list[2];
col3 = selected_column_list[3];
col4 = selected_column_list[4];
// Create a new table using just the two selected columns
dt2 = dt << Subset( columns(column(dt, col1), column(dt, col2), column(dt, col3), column(dt, col4) ) );
col_dlg << close window;
)
);
Data table added.
Message was edited by: Luqman Olawin