Hi, I have filtered the columns from input excel file using “filter data table” activity and write their data into output excel file using write range activity
Now, for some of column I have to split their data and write it into output excel file.(For ex. In Height column there is data like 134cm, 136cm, 176cm etc. Here i need only 134,136 and 176. ‘cm’ should get remove.)
Now after using splitting logic, how can i use that variable in write range activity? I am getting the error as "Value of type ‘String’ cannot converted to ‘System.Data.DataTable’
How can i solve this?
Thanks in Advance!
Hi @Rohit_Patil1 ,
Could you let us know the Method used for the Splitting?
We could basically update the column Height using a For Each Row
Activity and achieve your result. Have you tried it ?
Hey!
Instead of Write range use Write cell activity!
Regards,
NaNi
Hey @THIRU_NANI I used write cell but instead of actual value of column, “Data Table” is printed in output excel file
Hey!
In this case use Add data row activity
Then use write range
Regards,
NaNi
We cannot convert the Datatable to String in that manner.
We can use an Output Datatable
Activity to convert Datatable values to String.
However, You would only require to use For Each Row
Activity and Update the Height column like below :
Hi @supermanPunch What data table value should I pass in write range activity then?
It should be DT3
, as we are updating DT3
datatable values.
Hi @supermanPunch Thanks! It worked.
But supposed we have similar columns like that for eg. Weight like 43kg,44kg etc, Distance like 3km, 5km etc
The same logic will worked by using the assign activity?
@Rohit_Patil1 , Yes. It should work.
Thanks! Let me try this also.
Hello @Rohit_Patil1
Another method is diretly convert datatable to string using putput datatable acitvity and then use replace command to replace all the cm, instead of using for each row.
DT1-> strVal. (strVal is string variable)
strVal.Replace(“cm”,“”)
After replacing you can use Text to datatable activity and convet again to datatable .
Hi @Rahul_Unnikrishnan I will try using this method also.
@supermanPunch It worked. Thanks a lot.!
Hi @supermanPunch, What if i have string like $12kg, @123cm, #23mm. I want to extract only integer part from above string that is 12 , 123 ,23 etc.
how can I extract it by following this approach?
You Can use Following Expression to Extract only Integer value,
System.text.RegularExpressions.Regex.match(strValue,“\d+”).ToString
Regards,
Saloni
Heyy! @Rohit_Patil1
It’s better to create a new thread. Since this thread already closed.
Regards,
NaNi
Hi @sb001 Currently i am using this method to replace the unit(cm) and got the numbers only. but now unit can be any like cm, kg, mm etc.
So how can i get only integer value from that string using this method.
For more understanding kindly read previous messages. Thanks!
Hello @Rohit_Patil1
This is a Regex Method and You can also use this method to extract Integer values From any Type of unit.
e.g. 123cm,5kg,150mm it will only extract 123,5,150 integer values from your string.
Regards,
Saloni