Hi There,
Please find attached sheet.
There is two different columns in excel sheet ‘Creation Fields’ & ‘Request Fields’ & their values.
I want to read this columns as dictionary
Key - ‘Creation Fields’ & Value - ‘Creation Fields Value’
Key - ‘Request Fields’ & Value - ‘Request Fields Value’
How to achieve this ??
Book1.xlsx (10.3 KB)
Hi @Muralikrishna_Surve ,
Could you Check the below Expression :
Assuming you have the Excel data read as a Datatable, say DT.
dictVar = DT.AsEnumerable.ToDictionary(Function(x)x("Creation Fields").ToString,Function(y)y("Request Fields").ToString)
Here, dictVar is a variable of type Dictionary(Of String,String)
Hello @Muralikrishna_Surve
Kindly refer to this Xaml file, you will get some idea.
Forum_DTtoDict.zip (149.9 KB)
1 Like
Thank you @Gokul_Jayakumar for the reply.
In my excel sheet both ‘Key ’ & ‘Value ’ Column names is same ‘Creation Fields ’.
So it is showing error as “A column named ‘Creation Fields’ already belongs to this DataTable.”
Please find attached excel.
Book1.xlsx (10.3 KB)
Hello @Muralikrishna_Surve
This is due to the same name for all columns.
While reading range, we need unique Columns.
Try by change the columns name.
1 Like
In my process, I will be getting datatable same as above added. (Same column names)
So can I change Value(Column) Name temporarily to unique names ?
@Muralikrishna_Surve
If possible you can change the Column Name, Or else you can read data from Range “A2” and uncheck the Add Headers properties.
1 Like
@Muralikrishna_Surve ,
If this Data is being created by you, Then would suggest to change the format used. The C & D columns look also like Key-Value pairs like the A & B columns. You could append the data to the A-B columns and remove the data from C & D columns. Also renaming the Column A to Creation Fields - Key and Column B to Creation Fields - Value should be understandable and easier for usage.
Let us know if the data is not being created by you or if you cannot change the format.
1 Like
This data is not created by me.
This is standard format of datatable.
system
(system)
Closed
January 19, 2023, 8:17am
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.