Hey UiPath group think! I feel like I am brain farting here.
I have a data table and I want to add a column that will contain the row index number. What will be the best way of going about this?
Thanks!
-James
Hey UiPath group think! I feel like I am brain farting here.
I have a data table and I want to add a column that will contain the row index number. What will be the best way of going about this?
Thanks!
-James
@jamills after using the âAdd Data Columnâ activity pointed out by @lakshman, you should use a âFor Each Rowâ activity and put the following in an assign activity (assuming datatype is integer, if datatype is string, just append .ToString at the end on the right side of the assign activity): Assign row.item("YourNewColumnName") = YourDataTableVariable.IndexOf(row)
Hello James,
Probably the best way to do this is to not add it if itâs not necessary and youâre just using it as youâre going through the data. The ReFramework has the index value TransactionNumber that you can use to reference the row in the TransactionData.
Thereâs also the For Each Rowâs index: https://docs.uipath.com/activities/docs/for-each-row#section-output
If you absolutely need it in with the data, the Add Data Column should do as @lakshman stated. However, you would have to set the datatype to Int32 and check the AutoIncrement option I believe and it should automatically populate with the numbers you need.
Hey everyone! I really appreciate the quick responses! Iâm going to go through and try out your responses.
To anyone that ends up reading this in the future. Daveâs solution worked. If you have trouble the right side of the assign, you can always create another assign that counts each row: rowIndex (this needs to be an int) = rowIndex + 1. And his assign will read as: Assign row.item(âYourNewColumnNameâ) = rowIndex
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.