How can we store the text extracted from document as key value pair in dictionary?

How can we store the text extracted from document as key value pair in dictionary?

Sample text in the document

Name: ABC
RollNo: 101
Marks: 585

#getText #StringFunction #Dictionary #user-voice:studio
How can we store the text extracted from document as key value pair in dictionary?

Sample text in the document

Name: ABC
RollNo: 101
Marks: 585

#getText #StringFunction #Dictionary #user-voice:studio

Hi @alok.pandey

when working with dictionaries you should install the Microsoft.Activities.Extensions package it has some very useful activites.

a bit more information would be useful:

First of all, how do you extract the data from your document and in which format?

If you use document understanding to extract the data, it should already be in form of a datatable. There’s no reason to convert a datatable to a dictionary.

If you extract it with readpdf and/or string manipulation, you’ll first have to split the string (e.g “Name: ABC”) into two parts and then add it to the dictionary with the activity Add to dictionary.

If this answers your question, please mark it as answer, if not, feel free to ask further questions.

Cheers,
T0Bi

Hi,

Can you try the following expression?

dict = text.Split(vbcrlf.ToCharArray,StringSplitoptions.RemoveEmptyEntries).ToDictionary(Function(x) System.Text.RegularExpressions.Regex.Match(x,"^[^:]*").Value.Trim, Function(x) System.Text.RegularExpressions.Regex.Match(x,"(?<=:).*?$").Value.Trim)

img20201224-2

Regards,

2 Likes

@Yoichi Thanks a lot it worked.

1 Like

Hi @T0Bi Thanks for your response. I was extracting data from normal text file.
your answer really helped.

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