I want to read a string from a text file and such as “24+35” and write the result of this mathematical expression into another text file. How can I convert this string to an array and perform the mathematical operation on the required numbers?
Hi
Welcome to uipath community
usually to convert a text to string array
we do like
out_str_array = yourtextvariable.Split(Environment.NewLine.ToArray())
where out_str_array is a variable of type string array
but i would like to know how you want to get the value
kindly provide a sample and elaborate a bit more the requirement pls that could help us go in right direction
Cheers @Mrud2517
Hi @Mrud2517
Welcome to the community.
Hope this might be helpful to you.
Scenario 1: Use read text file Activity Read Text File Activity Note: It will return string value.
Scenario 2: Create a variable and declare it as an array of string:
Scenario 3:
After getting the value using split Environment.NewLine option spit the value to array
For loop through the array value you can get the each value .
arrStr= strPathvalue.Split(Environment.NewLine.ToArray, StringSplitOptions.RemoveEmptyEntries)
cheers
Happy learning
Hi. So my requirement is to read a mathematical expression from a text file, process it and get the output, and write that very output to another text file. Which function will be apt for this and how should I go about this?
for this we can use READ TEXT FILE activity and get the output as a string output variable named out_text
then
to process this it depends on the process (we need some more details on it)
i hope you were asking for this (not sure)
we do like
out_str_array = yourtextvariable.Split(Environment.NewLine.ToArray())
where out_str_array is a variable of type string array
for this we can use write text file activity
Cheers @Mrud2517
So by process it I mean I need to get the answer for my mathematical expression
Main.xaml (5.6 KB)
So for you guys to understand my task better, I have uploaded the screenshots of the files. The bot has to read the first file, calculate the answer and then write the answer to another text file. My Xaml file is not the entire workflow of the task yet as I was checking if the bot is able to log the characters separately in a for loop. Thanks for all the help till now am new to this community and just started learning.