How to read dictionary values

Hi Team,

Hope everyone is safe and good.

image

I need help on how to read value from dictionary
In this, I don’t have column name.“column 0” is my key and “column 1” is my value.Need to read A with Sharan, B with Mahesh etc.

Steps:
1)assign activity with value as new Dictionary(of String, String)
2)Read range with giving details of sheet name, path and output as dt
then how to move further? I am not getting.

Can anyone will guide me please
This is the sample excel sheet

Hi,

Hope the following helps you.

img20200724-2

Regards,

1 Like

@Sharanabasava_Kallur Follow the below Steps :

  1. Use For Each Row on DT.
    Inside For Each Row use Assign Activity in the below way :
    dictVar(row(“Column0”).ToString) = row(“Column1”).ToString
1 Like

@Sharanabasava_Kallur
use assign
left side your dict
right side:
YourDataTableVar.AsEnumerable.ToDictionary(Of String, String)(Function (r) r(YourKeyCol).toString, Function (r) r(YourValueCol).toString)

find demo here:
DataTable_2Col_ToDictionary.xaml (6.5 KB)

3 Likes

I am getting this error
Assign: Cannot create an L-value from the given expression with property ‘set_Item’ because the target object is null.

1 Like

Hi,

Did you create an instance for dictVar as the following?

img20200724-3

Regards,

init the dict before with new Dictionary(Of String, String) e.g. default value on variable panel

I cannot use build data table,beacuse I want to read an excel and that value need to paste into different excel.
Thanks

the demo code was intented to show on how the datatable can be brought to a dictionary. For sure it will work also with the datatable that you have received with the read range by readin the excel

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