Trim data

Again, my apologies for simple questions, but I am new and trying to learn.

I am trying to manipulate some data that is currently within a datatable.

The data that I am trying to manipulate has leading spaces and ending spaces.

In my mind, I thought that the trim function would work, but I am struggling to get the function to work.

I can use the trim function in a messagebox

trim(CurrentRow(“Name”).ToString) + trim(CurrentRow(“Number”).ToString)

However, I can’t get the trim to work on the “Add Data Row”, in fact it won’t let me type the word trim anywhere.

I am sure htis is a simple question, but i am just trying to learn

image

give a try on
{CurrentRow("Name").toString.Trim, CurrentRow("Number").toString.Trim}

Hi @daryl_pressley

You can also use this method

Use Assign activity

LHS → Create an Variable
RHS → Currentrow(“Column Name”).Tostring.Trim

Use Add data Row Activity

Pass the variable in the [ArrayRow]

Regards
Gokul

1 Like

@ gukul001

i am getting the following error message

Does this mean i need to set a value somewhere for dt?

If so what vaue and where?

image

Can you scare the error message and screenshot of the workflow @daryl_pressley

Here is a screenshot of workflow and error message

Do you need the entire workflow?

dt is not properly initialized, is it?

Can you check the Data Table is not set correct @daryl_pressley , Share the workflow and input file if possible

How do i initialize it? Again, I am a newby. Sorry for stupid question

I can’t share files on here, I am still new i guess, the forum won’t allow me to yet

you can use the Build datatable Activity,

  • configure the 2 columns

ensure an empty datatable is generated - dt

then use it as done in your screenshots

here we also recommend: UiPath Academy

Input file pic

image

Hi @daryl_pressley ,

While using the Add Data Row Activity, make sure you have the Datatable ready, We can use an Existing Datatable which follows the Number of Values that you assign to the Array Row Property with it’s number of Columns.

or We can define the datatable using the Build Datatable Activity with two Columns of the Datatypes you require.

Can you check the dt that you have assigned in the Add data row activity.

May be the excel file contains the empty values @daryl_pressley

Here is the sample workflow for you reference @daryl_pressley

Sequence1.xaml (17.4 KB)

Regards
Gokul

looks like you want to trim the existing values and write them back to the same data table. In such case we would use a

For each row in datatable

  • assign: CurrentRow(“Name”) = CurrentRow(“Name”).toString.Trim
    same for Number

I tried the sequence you sent, but i am getting following error message

Hi @daryl_pressley,

Looking the error I am assuming you are working on the same DT and also modifying the same DT as well. Is it ??

Thanks

yes that is correct.