Hello,
I'm having a bit of trouble copying columns from multiple data tables into new blank table. The data tables to be opened all have the same column names.
So far, I can open multiple tables but can only copy columns from one the latest data table opened.
Here is my code below:
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 - 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 );
);
//Create Column Copier to copy files
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;
)
);
Note: The new data table which is created is a subset of the latest data table opened from the multiple data table. I would like to be able to choose any copy any column from any of the data tables into the new one. Thank you.