Rename column using first row's valueHi
I'm trying to name my column names based on the string word in the first row of every other column as per described in the picture.

My script can't seem to work. I am finding a way to get the string value in the first row but doesn't seem to work. Can you help me out?
dt = Current Data Table();
newname = dt << select rows (1) << print ;
For( i = 2, i <= N Cols( dt ), i=i+2,
Column( dt, i+1 ) << Set Name( newname );
);
Re: Rename column using first row's valueTry this script:
Names Default to Here( 1 );
dt = Current Data Table()
For( c = 2, c < N Col( dt ), c += 2,
Column( dt, c+1 ) << Set Name( Column( dt, c )[1] );
);
Re: Rename column using first row's value@Mark_Bailey
Works well. You're missing a : after
dt = Current Data Table()
Should be
dt = Current Data Table();
Otherwise great
Re: Rename column using first row's valuein previous versions (<=18), one could use this workflow:
- duplicate the first row (we don't want to miss the entries in the next step)
- use Cols/Column Names/move-up to use the duplicate 1st row as temporary column names
- to shift the names by 1:
- copy the column temporary names via CTRL+C [done, but not visible in the video]
- delete the first column [otherwise name will be name2]
- mark the remaining columns
- paste the column names from the clipboard [please notice the change of the column names at the end]