String operation on rows of Datatable

Hi

I have a datable with the names of files in a folder. I am trying to perform a string operation on all the values of the data table. I need to extract only the name of the company from the row. Can anyone help me with it. I am new to UIpath.

Hi
Welcome to uipath community
yah this can be done with REGEX or split method inside the FOR EACH ROW loop
if possible can we have an example
Cheers @Ankita_Biswas

@Ankita_Biswas
Welcome to our community
you can try this

out_dt.Rows(0)(“column_name”).ToString
0 is the row index

4 Likes

Can you please eleborate in steps, I have done the following steps.

  1. Create Datatable.
  2. For ech row in datatable
    a. assign operation on rows
    I am stuck here . I have names like XYZPty Ltd- Account Transctions, XYZPty Ltd- Trial Balance, Mapping -XYZPty Ltd
    I just need the XYZPty Ltd

Thanks

1 Like

Fine
inside the for each row loop use this in assign activity
str_output = Split(row(“yourcolumnname”).ToString,“-”)(0).tostring

Cheers @Ankita_Biswas

Can i store the output in some other datatable? How can i see the output?

yes you can of course
before FOR EACH ROW loop use BUILD DATATABLE ACTIVITY and create a table with one column of type string named “Mapped company” and get the output with a variable of type datatable named finaldt
–now inside the FOR EACH ROW loop use a ADD DATA ROW activity next to the abovve assign activity and mention the arrayrow property as {str_output} and in datatable mention as finaldt, so that it will add that splitted value to a datatable
–then we can use write range activity next to this for each row loop and write that to a excel file

Cheers @Ankita_Biswas

2 Likes

Thanks for the solution. I m getting an error . Could you please rectify where i m going wrong

May I know why do we use this assign activity
It’s not per the sequence buddy
After add Datarow and for each row activity we can directly use write range activity
Cheers @Ankita_Biswas

After Read Range :— Dt1
use Assign in that copy that datatable to other say
Dt2=Dt1
Then In For Each Row for Dt2
Assign
Row(“Company Name”)=Row(“Company Name”).tostring.split("-"c)(0)

So now in Dt1 your original Data and in Dt2 the updated data
You can see the output datatatble in message box by using
Output Datatatble and Message Box Activity

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.