cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Starwatcher
Level III

JSL_open and join data tables from a list in a for loop

Hello, I am trying to write a script to join tables in JSL, where we can input the number of tables to join. For this, I created lists to input html table location, tables names and joiner columns.

Before the join, I start by opening the tables, taking an element from the lists in a for loop.

I get an error message "Subscript problem in access or evaluation  of "tables_list[i]", tables_list[/*###*/].

Any idea what I did wrong? Thank you in advance for the support

// Indicate how many input data tables you have (default = 1)
nb_join_tables = 2;

// Indicate here the link to the first input HTML table
input_table_01 = "http://xxxx.html";
// Indicate here the names you want for your first JMP data tables
JMP_table_01_name = "xxx -01";

// Indicate here the link to the input HTML table to join
input_table_02 = "http://xxxx.html";
input_table_03 = "http://xxxx.html";
// Indicate here the names you want for the data tables to join
JMP_table_02_name = "xxx -02";
JMP_table_03_name = "xxx -03";

// indicate here the column you want JMP to use as joiner for the tables merge (default:Parameter Set Name)
joiner_table_01 = "Parameter Set Name";
joiner_table_02 = "Parameter Set Name";
joiner_table_03 = "Parameter Set Name"; // Create lists according to the number of tables to merge tables_list = {input_table_01,input_table_02,input_table_03}; names_list= {JMP_table_01_name,JMP_table_02_name,JMP_table_03_name}; joiners_list = {joiner_table_01,joiner_table_02,joiner_table_03}; For( i = 0, i <= nb_join_tables, i++, //Open html data table from specific location dt=Open( tables_list[i], HTML Table( 4, Column Names( 0 ), Data Starts( 1 ) ) ); // Set JMP data table name to the desired one dt << Set Name( names_list[i] ); );
1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: JSL_open and join data tables from a list in a for loop

this code

tables_list = {input_table_01,input_table_02,input_table_03};

makes a list of names of variables, not a list of the content of the variables. Open is seeing the name of the variable where it expects the content. You can use this to evaluate the names to their content:

tables_list = Eval List( {input_table_01,input_table_02,input_table_03} );

or you can build the list like this:

tables_list = {};
tables_list[1] = input_table_01;
tables_list[2] = input_table_02;
tables_list[3] = input_table_03;
Craige

View solution in original post

6 REPLIES 6
Craige_Hales
Super User

Re: JSL_open and join data tables from a list in a for loop

JSL lists and matrices start at 1. JMP uses for( i = 1, i <= n, i++, ... rather than for( i = 0, i < n, i++, .

 

 

Craige
Starwatcher
Level III

Re: JSL_open and join data tables from a list in a for loop

Hello Craige,

I tried also with n= 1 and it does not work neither. Actually, I've put i=1 to start with and tested to i=0 just in case and forgot to put i=1 again before posting.

Does not seem to be the issue though.

Any other idea?

Craige_Hales
Super User

Re: JSL_open and join data tables from a list in a for loop

add a debugging statement just before the place it fails:

For( i = 0, i <= nb_join_tables, i++,

show(i, tables_list); // check the log window for the output

//Open html data table from specific location
		dt=Open(
			tables_list[i],
			HTML Table( 4, Column Names( 0 ), Data Starts( 1 ) )
		);
// Set JMP data table name to the desired one
		dt << Set Name( names_list[i] );
);
Craige
Starwatcher
Level III

Re: JSL_open and join data tables from a list in a for loop

Here is the log :


i = 1;
tables_list = {input_table_01, input_table_02, input_table_03, input_table_04, input_table_05, input_table_06};
input_table_01
Open argument must be string in access or evaluation of 'Open' , Open/*###*/(tables_list[i], HTML Table( 4, Column Names( 0 ), Data Starts( 1 ) ))

Craige_Hales
Super User

Re: JSL_open and join data tables from a list in a for loop

this code

tables_list = {input_table_01,input_table_02,input_table_03};

makes a list of names of variables, not a list of the content of the variables. Open is seeing the name of the variable where it expects the content. You can use this to evaluate the names to their content:

tables_list = Eval List( {input_table_01,input_table_02,input_table_03} );

or you can build the list like this:

tables_list = {};
tables_list[1] = input_table_01;
tables_list[2] = input_table_02;
tables_list[3] = input_table_03;
Craige
Starwatcher
Level III

Re: JSL_open and join data tables from a list in a for loop

Great, thank you, that works!!