Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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
Comment

PREVIOUS NEXT
Code Example
Java :: how to set slected row color in javafx tableview 
Java :: crazy error 
Java :: sudoku 6x6 java 
Java :: List of tuple to map + jpa 
Java :: Java Single-line Comment 
Java :: what is assignment in java with example 
Java :: try catch not working java 
Java :: java @documented 
Java :: convert zipfile to bytebuffer 
Java :: file with line numbers inserted java 
Java :: Java Remove EnumSet Elements 
Java :: java private access modifier 
Java :: priority queue size jaa 
Java :: Java Single element Annotations 
Java :: itext new page 
Java :: Java Creating ConcurrentHashMap from Other Maps 
Java :: TestNG Data Provider example 
Java :: code converter from java to python 
Java :: how to clear scoreboard with offline players java 
Java :: sorting boolean array with prime index 
Java :: Java/Perl - "sprintf function in java" or "string format" 
Java :: Which package contains the Math classin java? 
Java :: witch dependency is needed for "ArraysUtils" for the Import? 
Java :: fibonacci for biginteger 
Java :: synchronized method in java 
Java :: index out of bounds exception java 
Java :: android java random fragment on create 
Java :: Labeled continue Statement Java 
Java :: Dhttps.protocols=TLSv1.2 
Java :: java get parent process name 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =