Have to extract Recent Electronic sign

Hi,

I have a scenario where i have to extract most recent Electronically signed by ‘Name’ by considering both date & time. I may get any number of Sign’s… It can be one or more.

For eg input will be as below:
Electronically Signed By: Christine Robert, PT, License 7589 June 15, 2024 2.59 PM
Electronically Signed By: Roxanne Robes, PT, License 7589 June 15, 2024 3.20 PM
Electronically Signed By: Christine Robert, PT, License 7589 June 14, 2024 4.59 PM

I need to get output as Roxanne Robes - as it is the most recent. Kindly help me on the above task.

Hi @Somanath_Somu

Store the Input data in a variable called InputData. You can get the result by using the LINQ Expressions,

- Assign -> InputData = "Electronically Signed By: Christine Robert, PT, License 7589 June 15, 2024 2.59 PM
                         Electronically Signed By: Roxanne Robes, PT, License 7589 June 15, 2024 3.20 PM
                         Electronically Signed By: Christine Robert, PT, License 7589 June 14, 2024 4.59 PM"

- Assign -> RecentDate = System.Text.RegularExpressions.Regex.Matches(InputData, "[A-Za-z]+\s+\d+\,\s+\d+\s+\d+\.\d+\s+[A-Z]+").AsEnumerable.Select(Function(dateStr) DateTime.ParseExact(dateStr.Value, "MMMM dd, yyyy h.mm tt", System.Globalization.CultureInfo.InvariantCulture)).OrderByDescending(Function(dt) dt).First().ToString("MMMM dd, yyyy h.mm tt")

- Assign -> OutputName = System.Text.RegularExpressions.Regex.Match(System.Text.RegularExpressions.Regex.Matches(InputData, "Electronically Signed By\:.*").AsEnumerable().Where(Function(X) X.Value.Contains(RecentDate)).Select(Function(X) X).first.toString, "(?<=Electronically Signed By\:\s*)[A-Za-z\s]+").Value.ToString.Trim

InputData, RecentDate and OutputName are String datatype variables.

The Output is stored in a variable called OutputName.

Check the below workflow for better understanding,
Expressions_Practice.xaml (13.0 KB)

Hope it helps!!

Hi @Somanath_Somu

Try this:

Assign activity ->
 inputStrings = {
                "Electronically Signed By: Christine Robert, PT, License 7589 June 15, 2024 2.59 PM",
                "Electronically Signed By: Roxanne Robes, PT, License 7589 June 15, 2024 3.20 PM",
                "Electronically Signed By: Christine Robert, PT, License 7589 June 14, 2024 4.59 PM"
                 }

Assign activity -> 
mostRecentName = inputStrings.Select(Function(s) New With {
    .Name = System.Text.RegularExpressions.Regex.Match(s, "Electronically Signed By: (.*?), PT").Groups(1).Value,
    .Date = DateTime.ParseExact(
        System.Text.RegularExpressions.Regex.Match(s, "(?<=\d{4} ).*").Value.Replace(".", ":"), 
        "MMMM dd, yyyy h:mm tt", 
        System.Globalization.CultureInfo.InvariantCulture)
}).OrderByDescending(Function(x) x.Date).First().Name

inputStrings is of DataType Array(System.String). mostRecentName is of DataType System.String

Hope it helps!!

Hi, i will be getting this input in IEnumerable type after using Regex, so can you please say how to convert this input into string & get the correct output

Could you show me the how you are getting input or else what the input data datatype… @Somanath_Somu

Hope you understand!!

Hi @mkankatala ,

Attached input file fyr.
InputData.txt (4.0 KB)

Got it @Somanath_Somu

Follow the below steps,
→ Use the Read Text file activity to read the text file and store in a string variable called InputData.
→ Then use the assign activity to write the regular expression to extract the required data and store it in the same variable called InputData as below,

- Assign -> String.Join(Environment.NewLine, System.Text.RegularExpressions.Regex.Matches(InputData.ToString(), "(Electronically Signed By\:.*)"))

→ Then use the below LINQ Expression to get the latest date and time from the extracted data.

- Assign -> RecentDate = System.Text.RegularExpressions.Regex.Matches(InputData, "[A-Za-z]+\s+\d+\,\s+\d+\s+\d+\:\d+\s+[A-Z]+").AsEnumerable.Select(Function(dateStr) DateTime.ParseExact(dateStr.Value, "MMMM dd, yyyy h:mm tt", System.Globalization.CultureInfo.InvariantCulture)).OrderByDescending(Function(dt) dt).First().ToString("MMMM dd, yyyy h:mm tt")

→ Then use one more assign activity to get the output name which has the recent date.

- Assign -> System.Text.RegularExpressions.Regex.Match(System.Text.RegularExpressions.Regex.Matches(InputData, "Electronically Signed By\:.*").AsEnumerable().Where(Function(X) X.Value.Contains(RecentDate)).Select(Function(X) X).first.toString, "(?<=Electronically Signed By\:\s*)[A-Za-z\s]+").Value.ToString.Trim

Check the below workflow for better understanding,
Expressions_Practice.xaml (13.8 KB)

Hope it helps!!

Hi @mkankatala ,

Actually the input file type is PDF, after reading the PDF am using the logic u shared but still am unable to get the output.

Now am attaching the actual input file, can u please check & provide an solution
Input_PDFFile.PDF (157.6 KB)

Hi @mkankatala ,

Got the output & code is working fine.

Thank you very much for the solution!

1 Like

It’s my pleasure… @Somanath_Somu

Happy Automation!!

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