Updating data in a DataTable

I am getting back to this UIPath test, and and am continuing this thread How to I add data to a cell in a DataaTable?, but I have to start a new thread… because Discourse?

I have a datatable with data in it. It started with data in it, and then I added 3 columns. I’d like to populate those columns with information. What methods can I use to do that? I expected some kind of updateCell method, where I would update a cell based on the row number, or based on some kind of match with some data on the row. I can’t find such a method, and I don’t think the other thread understood what I was asking for.


FOR TESTING PURPOSES, I am outputting the datatable to a CSV file, so that I can make sure the code is working the way I want. This should make it easier to visualize what I’m trying to do.

The code is NOT using the CSV any further, that’s just me looking at things.

Hi @Robot.Builder.9001

you can do read csv and give delimiter as , and use Generated Datatable activity

and then use write csv or range

Ashwin S

Hello @Robot.Builder.9001!

The most simple approach to this use-case is the following:

  • Use a For Each Row loop to iterate through every row in the table.
  • Inside the For Each Row, use an Assign activity:

my_datatable.Rows(row).Item(n) → where “n” is the column index or name.

desiredValue → value you’d want to add to your table.

I hope this response helps you! If you want, I can send you an example workflow of this workaround that’s working perfectly :slight_smile:

Keep it up!

1 Like

That sounds like it would work great, except something in that line wants an integer and is instead getting a string. for “n” I tried the name of the colum (in quotes and out of them), and the numerical position, and get the same error. Which I can’t copy because it only shows up on a mouseover.

I can’t find any related documentation on the docs site.
On the docs site, when I search for row, all that is found on things for columns.
On the docs site, this is what’s returned for a datatable guide https://docs.uipath.com/integrations/docs/office365-quickstart-create-write-read, which clearly has almost no bearing to learning how datatables work.

I can’t find any information about .Item() to try to figure out what its syntax is, nor can I find out what datatable.rows is looking for either.

I started working on this test weeks ago, it’s supposed to be simple, and I’m getting frustrated with what should be stupid-simple methods that should exist, and docs that want to steer you in the opposite direction.

Okay, so let’s get deeper into this problem.

In normal conditions, you should be able to assign the value stating the column name between double quotes in the Item clause (taking by example the row Index = 0):

TABLE_TEST.Rows(0).Item("ColumnName") = stringVariable
TABLE_TEST.Rows(0).Item("ColumnName") = int32Variable.toString

In your case, seeing the CSV file you’ve uploaded, I propose the following workaround:

→ Start a For Each Row loop in the table.

FOR EACH row IN DataTableName

→ Then, add the sentence I’ve detailed below, with the counter set up.

ASSIGN row.Item("SHA1 Hash") = stringVariable // if the variable is String type
ASSIGN row.Item("SHA1 Hash") = int32variable.toString // if the variable is Int32 type

ADVICE: Start debugging the process with a breakpoint in the assign activity inside the For Each Row loop and check if it’s working.

I hope this helps!

It sounds to me like there’a a super-secret way to enable line code mode and get rid of this annoying GUI that gets in the way. How do I do that?

There’s the text of the error. I tried reversing the assign, and this is where it wound up. Same error in either direction, or if I put text or int in there.

Bad news my friend… The code mode is not available, as far as I know.

Workflows are .xaml files interpretated by UiPath Studio as code. Below the activities there is some code but they are some sort of black box for us the developers.

The only thing to code the functionalities as you want, is to build your own activities, and that requires a lot of effort (it really does :frowning:)

I hope I had helped you!!

Alan F. Castro


If you are inside the For Each Row loop, you can try setting up the activity the following way:

row.Item(6) = clientIDTemp


Yes, I was already in a foreach at that point.

That worked! I wound up using the name of the column in quotes, which is how I was doing it in the foreachh loop.

So, aside from hulk-raging at the computer and asking on the forum, how was I supposed to know about this method? Is it supposed to be obvious and I missed it? All of my searches were turning up red herrings, and I still can’t find any info on the docs site about this.

Some times there is no other option than raging a little bit, unfortunately.

This is a .net method, which isn’t UiPath’s property so I understand they do not include this in the courses because it’s not their own technology. The courses teach looping and using activities, but any out-of-the-box solution to different problems have to be investigated on your own.

Maybe if you’re starting to involve with UiPath, my recommendation is to investigate some of the most common .net methods (mostly points like iterating, recurrence, or some System methods you can utilize, such as System.DateTime or IO.File).

Best regards and happy automating!


P.S. If this helped, don’t forget marking this post as solved! :slight_smile: :slight_smile:

1 Like

Hi @mancl0ud,

I’m not sure I understand your problem entirely. Is it that you don’t know how to assign a cell in a datatable a value? You can do this based on row index, cell index, column index, column header, whatever. If you want to set the values based on the value of another cell you can do that with a conditional, and if you want to set them all to some default value you can easily do that too without using a for each loop.

If you are having trouble with datatypes (eg you are trying to write an integer to a string cell) that’s something else. Depending on what you intend to do with the datatable, you could use object datatypes or cast the values to the correct type while assigning them.

Am I misunderstanding the problem? :slight_smile:

@pduffy Yes, you completely misunderstood everything. I’m the OP, and I’m the one that had the problem. I wanted to update the value in a “cell” (cell being a row, column coordinate) of a datatable, and could not find the command/method/syntax to do that.

@mancl0ud gave me the command:

row.Item(6) = clientIDTemp

which did the trick.

Yes, that’s exactly what I thought you wanted to do. Sorry for replying to @mancl0ud by accident. Glad you got a solution that works for you :+1:

One problem with never having had a box to be outside of, is that I always quickly find myself out of the box when I’m trying to learn a new language.

I’ve taken the UIPath training, and working on the final, and I’ve taken 2 Udemy courses on UIPath, but it seems I’ve got a ways to go…

And more importantly, it’ll be here for the next person!

1 Like

FYI you can set the value by column name too, depending on what works best for you. I thought the problem was more complex by all the discussion around it, sorry for the confusion I’m just on here for a few minutes :slight_smile:

but what will do if you do not know the row number

using for each row loop is not a good solution to update data in a particular row as it will traverse to each row unnecessary.

In my case, I was updating some of the cells as I was already going down the rows.