Subscribe Bookmark RSS Feed

how do I change column 1 name from all open data table

swu2

Occasional Contributor

Joined:

Jan 27, 2017

openDTs = List();

For( i = 1, i <= N Table(), i++,

Hello All,

 

I want to change the column name from all open data table, but my script only changed the last data table, would you please help?

openDTs = List();

For( i = 1, i <= N Table(), i++,

Insert Into( openDTs, Data Table( i ) ));

For( i = 1, i <= N Items(openDTs), i++,

column(1)<<openDTs[i]<<set name("DATE");

show(openDTs[i]));

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Justin_Chilton

Joined:

Aug 27, 2015

Solution

The way your code is written now does not work because Column(1) references the first column in the current data table and therefore will only change the column name of a single table. It seems like your placement of openDTs[i] is a little off. Below is how you would address this.

openDTs = List();
For( i = 1, i <= N Table(), i++,
	Insert Into( openDTs, Data Table( i ) )
);
For( i = 1, i <= N Items( openDTs ), i++,
	Column( openDTs[i], 1 ) << set name( "DATE" )
);

However, a better way to do this is to only use a single loop and set the name of the column use the Data Table function with a table index. This avoids looping to create a list and then looping that list to set the names.

For( i = 1, i <= N Table(), i++,
	Column( Data Table( i ), 1 ) << set name( "DATE" )
);

 

Justin
3 REPLIES
Justin_Chilton

Joined:

Aug 27, 2015

Solution

The way your code is written now does not work because Column(1) references the first column in the current data table and therefore will only change the column name of a single table. It seems like your placement of openDTs[i] is a little off. Below is how you would address this.

openDTs = List();
For( i = 1, i <= N Table(), i++,
	Insert Into( openDTs, Data Table( i ) )
);
For( i = 1, i <= N Items( openDTs ), i++,
	Column( openDTs[i], 1 ) << set name( "DATE" )
);

However, a better way to do this is to only use a single loop and set the name of the column use the Data Table function with a table index. This avoids looping to create a list and then looping that list to set the names.

For( i = 1, i <= N Table(), i++,
	Column( Data Table( i ), 1 ) << set name( "DATE" )
);

 

Justin
swu2

Occasional Contributor

Joined:

Jan 27, 2017

Thank you very much, it works

txnelson

Super User

Joined:

Jun 22, 2012

this should work

Names Default To Here( 1 );
openDTs = List();
For( i = 1, i <= N Table(), i++,
	Insert Into( openDTs, Data Table( i ) )
);
For( i = 1, i <= N Items( openDTs ), i++,
	Column( openDTs[i], 1 ) << set name( "DATE" );
	Show( xx );
);
Jim