I have once scenario in apachi nifi, that is i have a csv data in the flow file and i have the some csv data in my database which has some different data than the csv flow file, now i want to compare both csv files(flow file content from my nifi flow file and ,csv data which i read from database) using groovy script, could you please help me how can i achieve this using nifi. I have my data like below.
existing content(123_456.csv) from db
A 3000 AAA008
A 3001 AAA008
A 3002 AAA008
A 3003 AAA008
A 3005 AAA008
A 3006 AAA008
A 3007 AAA008
A 3008 AAA008
A 3009 AAA008
A 3010 AAA008
A 3011 AAA008
A 3012 AAA008(This record is deleted in the new file from the flow file, so i dont need to consider this from the new file)
Flow file content(123_456.csv) from apachi nifi flow file
A 3000 AAA008
A 3001 AAA008
U 3002 AAA009(This I need to update, since the third Colum is changed)
A 3003 AAA008
I 3013 AAA113(This I need to insert ,since I don't have this in the old file from the db)
A 3005 AAA008
A 3006 AAA008
A 3007 AAA008
A 3008 AAA008
A 3009 AAA008
A 3010 AAA008
A 3011 AAA008
Could you please help me with the groovy script, to achieve this. Thank you
Create 2 lists A & B Create 2 Sets A-match & A-nonmatch Create 2 Sets B-match & B-nonmatch
Then loop through A matching up to B - Add matches to A-match Add non-matches to A-nonmatch Then loop through B matching up to A - Add matches to B-match Add non-matches to B-nonmatch
Now you have a sets of matches from A to B nonmatches from A to B matches from B to A nonmatches from B to A