To start out with,
colNames = dt << get column names;
For( i = 1, i <= N Items( colNames ), i++,
Column( i ) << set name( Column( i )[1] )
);
// delete the first row
dt << select rows( 1 );
dt << delete rows;
This will load all the column names into colNames
, loop over the list, and then set each name to its first element.
For your case, I would use a regex filter to loop over the column names, adding the columns beginning with "^C\d"
to a separate list.
colNames = dt << get column names;
badCols = {};
For( i = 1, i <= N Items( colNames ), i++,
cname = Column( colNames ) << get name;
If( !(Is Missing( Regex( cname, "^C\d" ) )),
Insert Into( badCols, colNames )
);
);
Show( badCols );
To then rename those specific columns, you can do the following:
For( i = 1, i <= N Items( badCols ), i++,
cname = Column( badCols ) << get name;
Column( cname ) << set name( Column( cname )[1] );
);
I'm still working on selecting the first cells of the relevant columns and deleting that cell (the column names), and you may also then want to delete the last row if it is empty, but this is a good place to start. I'll update when I figure that last piece out, but you may beat me to it.
I hope this helps.