I have two Notepad data1 and data2. I am trying to add a column (Result) to data1 on condition that
Column named TAX_TYPE (of data1) = TAX (of data2)
And
TAX_RATE (of data1) = Percent (of data2)
The column (Result) which is supposed to get added to data2 notepad will have true or false based on the above condition
Can anyone help to get a working flow
Data1
wade.txt (1.8 KB)
Data2
test1.txt (1.5 KB)
@dipon1112000
Read Data from Notepads:
Use “Read Text File” activity to read data1 and data2 into strings.
Convert Text to DataTable:
Use “Generate Data Table” activity to convert the strings from step 1 into DataTables (DataTable1 and DataTable2).
Add Column to DataTable1:
Use “Add Data Column” activity to add a new column named “Result” to DataTable1.
Use For Each Row:
Use “For Each Row” activity to iterate through each row in DataTable1.
Check Conditions and Update Result Column:
Inside the “For Each Row” activity, use an “Assign” activity to set the value of the “Result” column based on conditions.
row(“Result”) = If(row(“TAX_TYPE”).ToString = DataTable2.Rows(rowIndex)(“TAX”).ToString AndAlso
row(“TAX_RATE”).ToString = DataTable2.Rows(rowIndex)(“Percent”).ToString, True, False)
ppr
(Peter Preuss)
January 12, 2024, 9:04am
6
Data in Notepads are CSV data. So we can use Read CSV Activity
You can start and exploring Join DataTable (Left Join dt1 to dt2)
Afterwards we will postprocess the Join Result and can update / generate the marked Data1 as needed
pikorpa
(Piotr Kołakowski)
January 12, 2024, 9:25am
7
Hey @dipon1112000
you can try this solution:
BlankProcess70.zip (4.2 KB)
Thank you so much but the result is coming false for all the rows
ppr
(Peter Preuss)
January 12, 2024, 11:47am
9
Kindly note on some heade cleansings is recommended (more below)
Have a look at this lookup dict approach
dictLK = Dictionary(Of String, String) =
dtData1.AsEnumerable.ToDictionary(Function (x) x(2).toString.Trim, Function (x) x("TAX_RATE").toString.Trim)
So in a second step dt1 can be extended with the status column and can be updated by using the lookup dict for the Code and cheking the rate when looping over dt2
ppr
(Peter Preuss)
January 12, 2024, 12:04pm
10
Giving some more starter help:
Preps
Check
strKey = row2(“TAX”).toString.Trim
IF Condition
dictLK.ContainsKey(strKey) AndAlso dictLK(strKey).Equals(row2(“Percent”))
We do feel:
a few corrections are to do (at least the column issue from dt1 can lead to wrong LookUpDict
maybe the Percentage precions 0.5 vs 0.5000000001 are to harmonize
Feel free to adapt and to enhance
Hi @dipon1112000
Try this:
Test.zip (2.7 KB)
Hope it will helps you.
Happy Automation
postwick
(Paul Ostwick)
January 12, 2024, 3:55pm
12
You are missing the double quotes around TAX_TYPE - it should be row(“TAX_TYPE”) not row(TAX_TYPE). Also, rowIndex appears not to be declared. What do you have in the index property of the For Each Row in Data Table activity?
system
(system)
Closed
January 15, 2024, 3:56pm
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.