- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Extract file name from data table
Hi all,
I need to open data tables where the file names are being extracted from my main table and after opening the data table, it will merge it into one data table. Also, col2 have the same values inside dt.
It should look like this:
C:\Desktop\Name_Ana_Gender_Female.jmp
C:\Desktop\Name_Grace_Gender_Female.jmp
I have this code but it only opens one data table
dt = Data Table( "sample_table" );
col_name=associative array(column(dt, "name" ) <<get values) <<get keys;
col_gender=associative array(column(dt, "gender" ) <<get values) <<get keys;
file_list = N Items( col_name );
file_path = "C:\Desktop";
For( i = 1, i < file_list, i++,
dt1 = Open( file_path || "Name_" || char(col_name[i]) || " _Gender_" || char(col_gender[1]) || ".jmp",
//merge the two opened table
)
);
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract file name from data table
- Please take the time to go through the Discovering JMP and Using JMP documentation. They will help you learn about the fundamental features of JMP. Then, you will be able to use those features and then let JMP provide you with the JSL to create the scripts.
- There are several previous Discussion Tracks on the topic of reading in multiple data tables and then putting them together. Please start searching them. You will be able to solve your problems much faster.
- Here is a possible solution to your scripting needs. It is untested.
dt = Data Table( "sample_table" ); col_name = dt:names << get values; col_gender = dt:gender << get values; file_list = N Items( col_name ); file_path = "C:\Desktop\"; dtFinal = New Table( "Final Table" ); For( i = 1, i <= file_list, i++, dt1 = Open( file_path || "Name_" || Char( col_name[i] ) || " _Gender_" || Char( col_gender[1] ) || ".jmp" ); dtFinal << concatenate( dt1, append to first table( 1 ) ); Close( dt1, nosave ); );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract file name from data table
- Please take the time to go through the Discovering JMP and Using JMP documentation. They will help you learn about the fundamental features of JMP. Then, you will be able to use those features and then let JMP provide you with the JSL to create the scripts.
- There are several previous Discussion Tracks on the topic of reading in multiple data tables and then putting them together. Please start searching them. You will be able to solve your problems much faster.
- Here is a possible solution to your scripting needs. It is untested.
dt = Data Table( "sample_table" ); col_name = dt:names << get values; col_gender = dt:gender << get values; file_list = N Items( col_name ); file_path = "C:\Desktop\"; dtFinal = New Table( "Final Table" ); For( i = 1, i <= file_list, i++, dt1 = Open( file_path || "Name_" || Char( col_name[i] ) || " _Gender_" || Char( col_gender[1] ) || ".jmp" ); dtFinal << concatenate( dt1, append to first table( 1 ) ); Close( dt1, nosave ); );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract file name from data table
If col_name only contains one item then you would expect your code to open only one table. So why not start by looking at the contents of that list (use the show function). How many items does it contain? Next look at your loop - is it really looping over each item in the list? Perhaps you need "<=" instead of "<". I would also suggest that
1. you use meaningful names. I would expect file_list to be a list of files and col_name to be the name of a column.
2. don't put tons of logic into a single line, it's not clever - it just makes it impossible to debug.