How to combine and update file in java?
for example: 1.csv is id,item,score 1,1,1 1,2,2 1,3,3 2,1,1 2,2,3 2.csv is id,item,score 1,1,3 3,1,1 3,2,1 combine and update file 1,1,3 1,2,2 1,3,3 2,1,1 2,2,3 3,1,1 3,2,1
If this is a one-time task, then it is easy to accomplish in Excel.
just copy the contents of all the files into one column and delete, perform the operation to delete duplicates. Now copy the result to the final file.
If you need to perform this operation regularly, then you just need to read the files lines, for example like this:
List<String> lines = Files.readAllLines(Paths.get(inputFile.getPath()),
Charset.forName("UTF-8"));
and then add with verification !list.contains(line), for example, to the list