Reading from data table issue

I am having issues reading from a data table, I have a data table like this:
image

When I use a for each to assign each column to a variable and use a log message to see if the column name has come through like this:

the log message looks like this:
image

I am trying to assign each column to a variable

If you want to assign each column to a variable you don’t use Output Data Table.

You also don’t need to assign the columns to a variable. You can just reference the data directly. Can you give more detail about what exactly you’re trying to do?

I am trying to assign each column to a variable then use a read range activity and use that variable to navigate to a sheet in a file - but I am having issues with getting the column names

The data table is one row and multiple columns

Please could you explain how I would reference the data directly

The same way you do it in an Assign. If you’re using For Each Row in Data Table then you reference the value with CurrentRow(“column name”).ToString

Are you saying the one row in the spreadsheet has a different sheet name in each column?

That’s not really a good way to do it. It’s better to have one column and multiple rows (one row for each sheet name). Then you Read Range the Excel file into a datatable, and use For Each Row in Data Table to loop through the sheet names.

1 Like

Managed to get one column and multiple rows - is there a way or removing unwanted characters

@E.T.S

outputdatatable gives you the output as string if you use for each for that it will display like that only

can you explain clearly what you want to do

I want to assign a variable for each row of a data table so that I later on in the flow use the variable in a read range activity to navigate to a specific sheet in a file

@E.T.S

can you provide your input and expected output

so that i can help you

I have used a generate data table activity to get the data table to be one column as @postwick suggested and am getting this :

[Column 1
[
a_a
“,”
b_b
“,”
]
]

I would like to remove the ‘Column 1’ and the “,” from the data table (using a filter data table activity I am guessing) so that I can then assign each row to a variable - how would I configure the filter to achieve this?

Sure, what characters do you want to remove?

Column 1 is the name of the column, you can’t remove that. Columns must have names.

You don’t need to assign each row to a variable.

I suggest this (along with the rest of the free training): https://academy.uipath.com/courses/datatables-and-excel-automation-with-studio

1 Like

I would like to remove the rows that do not contain the data I want, so the rows that contain column names, [ and ], “,”

So that I am just left with:
a_a
b_b

The filter data table activity always confuses me as if I want to filter rows it does it by columns:
image

Please show us your source data. Something is not right about how you’re getting that stuff in your datatable.

The quotation marks are there as the transaction item has quotation marks

The [ and ] are there as the uploaded transaction item into the queue was an array

However I am not sure why the \n is there → I get data from an Excel file that looks like this:

When I log the variable it looks normal like this:
Data

Data

But when I upload as a transaction item it looks like this:
Data \n Data

Then you need to use Split to turn that string array into a real array. Then you don’t have to worry about removing characters.

Please could you explain how I would go about doing that :slight_smile:

Split(yourStringVar,",")

Actually, though, your string looks like a JSON array, so use…

JArray.Parse(yourStringVar).ToArray

1 Like

Update: Managed to edit to this:
image

Would that work as well

No, that won’t work.

Install UiPath.WebAPI.Utilities so you’ll have the JArray methods.