How to convert csv file to dictionary in uipath

i have a .csv file and i have to convert this file to dictionary in uipath

maybe some more details are to clear e.g. structures / datatypes

in general, we can do the following:

  • read CSV file into a datatable: Read CSV Activity - output dtData

Assign Activity:
myDict | Dictionary(Of String, Object) =

dtData.AsEnumerable.ToDictionary(Function (x) x(KeyColNameOrIndex).toString.Trim(),Function (x) x(ValueColNameOrIndex))


this is the csv file
and i have to convert to dictionary

we can fine-tune and defensive handle blanks from

read CSV file into a datatable: Read CSV Activity - output: dtData

Assign Activity:
myDict | Dictionary(Of String, String) =

(From d In dtData.AsEnumerable()
Let k = d("Name").toString.Trim
Let v = If(isNothing(d("Value")) OrElse String.IsNullOrEmpty(d("Value").toString.Trim), "", d("Value").toString.Trim)
Select a = New String(){k,v}).ToDictionary(Function (x) x.First(), Function (x) x.Last())

after the assign activity what is the next step
can you able to do the whole project
are you help me please

For sure you can also create the dictionary by using essential activites

Variable: myDict | DataType: Dictionary(Of String, String) | DefaultValue: new Dictionary(Of String, String)()

  • read CSV file into a datatable: Read CSV Activity - output: dtData
  • For each row Activity | row in dtData
    • Assign Activity: myDict(row(“Name”).toString.Trim()) =
If(isNothing(row("Value")) OrElse String.IsNullOrEmpty(row("Value").toString.Trim), "", row("Value").toString.Trim)

thats all - afterwards you will get the dictionary

share some sample data csv with us, when more help is needed

csv file was not uploaded how can i upload

rename it to txt or zip it

Test.xls (12.0 KB)
this is the fiile
Assign: Expression Activity type ‘VisualBasicReference`1’ requires compilation in order to run. Please ensure that the workflow has been compiled.
i got this error in assign

please help me @ppr


sometimes copy and paste is failling but when we retype the statements or at least retype every " then it will work

Find starter help here:
ppr_CSVBox_CSVToDict.xaml (6.9 KB)
Test.zip (3.1 KB)

this file is not open
it i showing document invalid

you can do this in your code

Assign: Expression Activity type ‘VisualBasicReference`1’ requires compilation in order to run. Please ensure that the workflow has been compiled.

it will sshow error

Main.xaml (8.1 KB)
project.json (1.8 KB)

had you retyped the expressions, if not please do it:

myDict(row("Name").toString().Trim()) =
If(isNothing(row("Value")) OrElse String.IsNullOrEmpty(row("Value").toString.Trim), "", row("Value").toString().Trim())

check your implementation that Row vs. row is correct

after assign activity what is the next step

thats all as already also shown in the screenshots