Add key and Value to Dictionary from String Array and Integer Array

I have string array and integer array I want to add key and value to dictionary .
How to add key and value to dictionary from string array and integer array using for each loop.

@muneeb

  1. Declare a dictionary say Dict of type(String,Int32)
  2. Initialize the dictionary using an Assign activity
    Dict (LeftSide) New Dictionary(of String, Int32) on the right
  3. For Each StrVar in StringArrayVariable (Assign the Index - In the property pane to an Integer say: getIndex)
    Add To Dictionary activity [Key: StrVar, Value: IntArrayVal(getIndex)]

Hi,

You can do it using the following expression, without loop, FYI.

arrStr.Zip(arrInt32, Function(k, v) New With {k, v}).ToDictionary(Function(x) x.k, Function(x) x.v)

img20200106-6

Regards,

1 Like

Add To Dictionary.xaml (8.8 KB)

@muneeb

Thanks!

Thanks to you.Can you share screenshort it is giving me error of “This activity is missing or cann’t be loaded”
image

Thanks @Yoichi

1 Like

Hi @muneeb

1.First create Dictionary object
use assign activity in_dic = new Dictionary(of String,Int)
2.Read excel data
Use Excel application scope pass the path where you save the excel file
and then use read range activity pass the sheet name create output data table variable.
3.use for each row activity pass the data table variable
and use assign activity in_dic(row(“KeyColumnName”)) = row(“Value”).

Regards,
Kommi Jeevan.

There is no row name in excel

excel contains column names or not?

Excel has no column names