Skip to content
Advertisement

How to compare 2 different csv files and output the differences without CSV-diff

I have 2 CSVs which are New.csv and Old.csv shown below:

New.csv

JavaScript

Old.csv

JavaScript

If there is a longName (first column) in in the new.csv that is not in the old.csv, I would like that entire new.csv row to be appended to the changes.csv. The current code below is done with csv-diff which seems be a bit glitchy and hard to work with. Is there an alternative way it could be done without csv-diff?

Output should basically look like this with the above CSV’s: enter image description here

CSV-diff code:

JavaScript

Advertisement

Answer

You can build a set of the longNames in the old csv and then check the new values against it.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement