We have a need to compare two CSV files. Let say file one have a few rows, and second file could have the same no of rows or more. Most of the rows could remain same on both files.Looking for the best approach to do a diff between these two files and read only those rows which has a difference in the second file from the first file. The application processing the file is in Java.
What are the best approaches for this?
Note : it would be great if we can know a row is updated, inserted or deleted in the second file.
Requirements:-
- There won't be any duplicate records
- File 1 and file 2 could have same no of records with a few rows with updated values in file2 (Records updated)
- File 2 could have a few rows removed ( this is treated as record deleted)
- File 2 could have a few new rows added ( this is treated as record inserted)
- On of the column could be treated a the primary key of the record, that won't change in both the files.