cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar

Try to rename multiple data tables

Hi friends,

 

I am trying to rename opened data tables in a project. I have two data tables, one has columns, the other one has 16 columns. I want to name the smaller data table as "Image" (this data contains lots of pictures) and the other one as "Numerical data".

 

My code works - for the first time. After the code changed the data table names correctly, If I manually change the correct named datable to something else, and run the code again ( I want to test the robustness of the script), it will not work.

 

Any suggestions are welcome!

 

 

Names Default To Here( 1 );

For( i = 1, i <= N Table(), i++,
    collName = Data Table( i ) << Get Column Names;
    If( N Items( collName ) == 2,
        Data Table( i ) << Set Name( "Image" ),
        Data Table( i ) << Set Name( "Numerical data" )
    );
);

 

 

2 REPLIES 2
Craige_Hales
Super User

Re: Try to rename multiple data tables

Thoughts (I have not tried it)

  • what does it do? Anything in the log?
  • print the names of the tables, before and after the change. What's in the log?
  • Are the tables saved? Internal or external to the project?
  • What JMP version? Projects improved a lot in 16 or 17 ... not sure exactly.

 

Craige
jthi
Super User

Re: Try to rename multiple data tables

Depending also where are you running your script from, you might have not access to your project. Projects have their own namespace(s).

Names Default To Here(1);

project = New Project(
	Run Script(
		Open("$SAMPLE_DATA/Big Class.jmp");
		Open("$SAMPLE_DATA/Probe.jmp");
	)
);

For(i = 1, i <= N Table(), i++,
	collName = Data Table(i) << Get Column Names;
	If(N Items(collName) == 2,
		Data Table(i) << Set Name("Image"),
		Data Table(i) << Set Name("Numerical data")
	);
);

vs

Names Default To Here(1);

project = New Project(
	Run Script(
		Names Default To Here(1);
		Open("$SAMPLE_DATA/Big Class.jmp");
		Open("$SAMPLE_DATA/Probe.jmp");
		For(i = 1, i <= N Table(), i++,
			collName = Data Table(i) << Get Column Names;
			If(N Items(collName) == 5,
				Data Table(i) << Set Name("Image"),
				Data Table(i) << Set Name("Numerical data")
			);
		);
	)
);

And if I run this from project (using JMP17) it does work for me

jthi_0-1693465270072.png

jthi_1-1693465287166.png

 

-Jarmo