Cndition I am using is not working: isNothing(row(“Credit”)) OrElse String.IsNullOrEmpty(row(“Debit”).toString.Replace(“-”, String.Empty).Replace(“,”, String.Empty).Replace(“.”, String.Empty).Trim)
For retaining only numbers for both columns you can use
Replace activity
Input is row(“Debit”).ToString.Trim
Pattern is “[\,\.\p{Zs}]*”
In the output, ctrl + k to create a string variable, let’s say strDebit which is a value you want
Replacement is String.Empty
You can do this with single line code in invoke code activity itself
dt1.AsEnumerable().Where(Function(row) row(“Credit”).ToString<>“” and row(“Debit”).ToString<>“”).ToList().ForEach(Sub(r1) r1.ItemArray={System.Text.RegularExpressions.Regex.Replace(r1(“Credit”).ToString,“[^0-9]+”,“”).ToString,System.Text.RegularExpressions.Regex.Replace(r1(“Debit”).ToString,“[^0-9]+”,“”).ToString})
I am assuming your excel had two columns Debit and credit
The columns I have in excel - Debit, Credit are amounts, I want to match the amount from excel and find in the dictionary key. I need to match it number sequence wise example:
If there is a match I want to update row(“Confirmation”) with “Yes”, then write in the file path which is saved is the dictionary value into row(“File Path”)
I am having trouble, any assistance would be appreciated
I was following this piece of code:
Use Dictionary.Keys to get a list of all Keys into a collection Example: keyColl = YourDictionary.Keys
'Loop through Excel Rows
For Each row in DataTable_Excel
'Get value of Excel Cell
cellValue = row(“column_name”).ToString()
'Check if the Excel value is contained in the Dictionary Key collection using the Contains function
'There are ways to do it using Lambda functions, but for now you may have to loop through the key collection
For each k in keyColl
if k.Contains(cellValue)= True then
get the filePath value of that key from your dictionary
filePath = YourDictionary(k)
'Write filePath to your Excel Cell in current row
'Write Confirmation to your Excel Cell in current row
end if
End For
End For
Just want to make sure I understood the use of this correctly:
If my value is: 1923 from excel, would it match 000192300 which is in my Dict Key, I understand string wise those are different values, just trying to match the number sequence
I hope you had a great weekend and thank you for your response.
I have manage to incorporate the logic you have shared, Im getting a match message box.
Sequence is:
For each data table
if - Checks if there is an empty cell or not
formats value(Matches) → strDebit output
for each - loops through keys
if → item contains string debit
assign → writing “yes” to column, It seems not to be writing, is it because the assign is in a normal For Each loop?
as the loop goes in order as the excel value, would I have to implement for the loop to iterate again to look for the value, while dismissing values that have already been found
Are you trying to update a field in a DataTable while at the same time also that use the same DataTable in For Each Row activity? If yes, you cannot do that.
First, copy the original DataTable then use the copied DataTable in for each row while the original DataTable for updating.