cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Jemster
Level III

Loop for Recode

I have several columns of data with numbers in.

When I import the data from excel some columns get imported as strings.

I would like to be able to loop through all columns and change their data type to integer.

The below script is an attempt to change one column.

col_list = dt << Get Column Names ()

dt << Begin Data Update;
dt << Recode Column(
	dt;col_list[21],
	{Num( _rcNow )},
	Update Properties( 1 ),
	Target Column( ;col_list[21] )
);
dt << End Data Update;

The command  below gives the right column but the code above gives an error on line 5 stating "Source column cannot be found in access or evaluation of 'Glue' , dt; /*###*/col_list[21] /*###*/;" I was wondering if I had to write the code as an expression then evaluate it and substitute the column into the relevant parts.

Show(dt;col_list[2]);
1 ACCEPTED SOLUTION

Accepted Solutions
Jemster
Level III

Re: Loop for Recode

I found replacing 'dt;col_lis[21]' with 'as column(col_list[21])' solved my problem

View solution in original post

1 REPLY 1
Jemster
Level III

Re: Loop for Recode

I found replacing 'dt;col_lis[21]' with 'as column(col_list[21])' solved my problem