Answers for "java code to get differences b/w two csv's into new csv"

0

java code to compare csv file against a table

HashMap<String, String> f1 = new HashMap<String, String>();
HashMap<String, String> f2 = new HashMap<String, String>();
// read f1, f2; use PK field as the key
List<String> deleted = new ArrayList<String>();
List<String> updated = new ArrayList<String>();
for(Map.Entry<String, String> entry : f1.keySet()) {
    if(!f2.containsKey(entry.getKey()) {
        deleted.add(entry.getValue());
    } else {
        if(!f2.get(entry.getKey().equals(f1.getValue())) {
            updated.add(f1.getValue());
        }
    }
}
for(String key : f1.keySet()) {
    f2.remove(key);
}
// f2 now contains only "new" rows
Posted by: Guest on July-16-2020

Code answers related to "java code to get differences b/w two csv's into new csv"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language