I keep running into an error with my script to rename data tables using a For loop.
Here's a simplified version of my script
OldNames = {"Old Name 1", "Old Name 2", "Old Name 3"};
NewNames = {"New Name 1", "New Name 2", "New Name 3"};
For( i, i <= NNames, i++,
dt = Data Table( OldNames[i] );
dt << Set Name( NewNames[i] );
);
I keep getting the following error
Cannot locate data table in access or evaluation of 'Data Table' , Data Table/*###*/( OldNames[i] )
However when I evaluate Data Table(OldNames[1]) there is no error!
Did you successfully run @jthi's script? If yes, then I suspect:
Below is a slight modification to @jthi's script. I make the 3rd table private, and I add show statements to the For loop.
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt = Open("$SAMPLE_DATA/Quality Control/Failures3Delimited.jmp");
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp", "Private");
OldNames = {"Big Class", "Failures3Delimited", "Semiconductor Capability"};
NewNames = {"New Name 1", "New Name 2", "New Name 3"};
For(i = 1, i <= N Items(OldNames), i++,
show(i, OldNames[i], NewNames[i]);
dt = Data Table(OldNames[i]);
dt << Set Name(NewNames[i]);
);
Here is the log output
/*:
i = 1;
OldNames[i] = "Big Class";
NewNames[i] = "New Name 1";
i = 2;
OldNames[i] = "Failures3Delimited";
NewNames[i] = "New Name 2";
i = 3;
OldNames[i] = "Semiconductor Capability";
NewNames[i] = "New Name 3";
Cannot locate data table in access or evaluation of 'Data Table' , Data Table/*###*/(OldNames[i])
at line 11 in Script.jsl
The JMP Scripting Guide states for private table that
This made me think that a private table might not have the same functionality, might not have teh names stored in memory since it is not counted.
Good luck!
Hi,
I changed the first two arguments of the For loop accordingly. It should work now:
OldNames = {"Old Name 1", "Old Name 2", "Old Name 3"};
NewNames = {"New Name 1", "New Name 2", "New Name 3"};
For(
i=1,
i <= NItems(NewNames),
i++,
dt = Data Table(OldNames[i]);
dt << Set Name(NewNames[i])
);
You seem to be missing at least definition for i (i = 1), also I'm not sure what NNames is.
This should be working example:
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt = Open("$SAMPLE_DATA/Quality Control/Failures3Delimited.jmp");
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
OldNames = {"Big Class", "Failures3Delimited", "Semiconductor Capability"};
NewNames = {"New Name 1", "New Name 2", "New Name 3"};
For(i = 1, i <= N Items(OldNames), i++,
dt = Data Table(OldNames[i]);
dt << Set Name(NewNames[i])
);
Sorry I realized I did miss the parts of my script while I was simplifying.
NNames = NItems(NewNames);
and i=1 for the first argument in the For loop.
Even with both of those defined correctly in my script I still get the same error message
Did you successfully run @jthi's script? If yes, then I suspect:
Below is a slight modification to @jthi's script. I make the 3rd table private, and I add show statements to the For loop.
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt = Open("$SAMPLE_DATA/Quality Control/Failures3Delimited.jmp");
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp", "Private");
OldNames = {"Big Class", "Failures3Delimited", "Semiconductor Capability"};
NewNames = {"New Name 1", "New Name 2", "New Name 3"};
For(i = 1, i <= N Items(OldNames), i++,
show(i, OldNames[i], NewNames[i]);
dt = Data Table(OldNames[i]);
dt << Set Name(NewNames[i]);
);
Here is the log output
/*:
i = 1;
OldNames[i] = "Big Class";
NewNames[i] = "New Name 1";
i = 2;
OldNames[i] = "Failures3Delimited";
NewNames[i] = "New Name 2";
i = 3;
OldNames[i] = "Semiconductor Capability";
NewNames[i] = "New Name 3";
Cannot locate data table in access or evaluation of 'Data Table' , Data Table/*###*/(OldNames[i])
at line 11 in Script.jsl
The JMP Scripting Guide states for private table that
This made me think that a private table might not have the same functionality, might not have teh names stored in memory since it is not counted.
Good luck!
Thanks a bunch. It was an issue with one of the table names and one tables being a private table.