Here are two large, same-structure csv files A and B. Their primary keys are Name & Dept fields. The two have some different records.
Use Java to compare primary keys of the two files to find records that exist in A but that does not exist in B according to the key values.
T()function parses a csv file; @c option enables retrieving data from a file that does not fit into the memory. sortx() function sorts data in a cursor. merge() function merges two cursors; @d enables calculating the difference.
The logic of the above code can be also expressed in a single SPL statement:
=[T@c(""A.csv"").sortx(Name,Dept),T@c(""B.csv"").sortx(Name,Dept)].merge@d(Name,Dept).fetch()
Read How to Call a SPL Script in Java to find how to integrate SPL into a Java application.
Top comments (1)
👍