Rename column in a for loopHi
I am trying to rename Column(3) as "Step i" for( i = 1, i<=3, i++), and I was using the script like below.
files={"path1", "path2", "path3"}
for (i =1, i<=3,i++,
dt = open(files[i]);
newname = "step"||i;
Column(3) << setname(newname)
); However, it doesn't work. It seems that the "newname" is not defined properly (I tried to show(newname) and nothing happened).
Can someone help me with the correct definition of the new name with "i" in it?
Thanks!
Zihao
Re: Rename column in a for loopFrom your first entry, you indicated that
"newname" is not defined properly
The log would have given a message about the concatenation
argument should be character in access or evaluation of 'Concat' , Bad Argument( i ), "step" || /*###*/i/*###*/
Make sure you examine all issues found in the log. Many times it is the first found issue that colors the additional items found.
Many times, to make it easy to see all of the errors for a given run, I will delete the log before running the script.
Re: Rename column in a for loopThe variable "i" is numeric and in order to be used in a concatenation, it needs to be a character variable. See below
files = {"path1", "path2", "path3"};
For( i = 1, i <= 3, i++,
dt = Open( files[i] );
newname = "step" || Char( i );
Column( 3 ) << setname( newname );
);