I used regex to pull dollar amounts from a section of PDF. How do I add them together now? and how do you convert ienumerable values to string?
Either you can use for each activity to convert ienumerable to string or you can use ienumerable_variable(0).ToString to get the first index item.
use a for each type ienumerable, then pass your variable and just get the item
hope it helps
If possible share the sample input file with an expected output
Try to use iEnumerable(0)
Hi @spemur01 ,
Some sample data would be really helpful because we are not sure what sort of IEnumerable it is, and whether we have to cast it and perform other operations to refine it before adding the values.
I am assuming that you are using MatchCollection, and if that is the case then here is a starter →
matches.Cast(Of Match).Where(Function(w) Not(IsNothing(w) OrElse String.IsNullOrEmpty(w.ToString))).Sum(Function(s) CDbl(s))
“Automated Manifest System $35.00 x 1 bill of lading $35.00
FCL - 40’ Container $16,515.00 x 1 container $16,515.00”
So here is the sample data that I am putting into the Match function. it’s storing all of those dollar amounts into the variable I screenshotted below. I found a way to remove every other member in the array so now it’s “35” and “16,515”. I need to add them together now. what should my next step be?
Hi @spemur01 ,
There are two way to sum up the values, and I have detailed both in this workflow.
Please have a look and let me know if it is as expected.
Single Step →
matches.Cast(Of Match).Sum(Function(s) Convert.ToDouble(s.ToString.Replace(",","")))
Using For Each ->(TypeArgument: System.Text.RegularExpressions.Match)
MatchandSum.xaml (7.1 KB)
This worked so well! thank you so much I was stuck on that for forever!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.