Compare 2 identical excel/ppt/csv files in nodejs

54
August 21, 2019, at 03:20 AM

I have a requirement where I want to compare 2 identical excel/ppt/csv files which may have exact same content but may be created at different point in time.

I want to compare only the file contents in whatever manner possible using any nodejs package.

But I couldn't figure out how it can be done in an easier way either by stream comparison or even buffer comparison also didn't help.

I've done more research but not much success and I'm just wondering how it would be possible to ignore certain things such as time stamp and any other metadata while doing comparison and only consider contents to match up.

I've tried stream-compare, stream-equal, file-compare, buff1.equals(buff2) and few others but nine of them seem to have worked for my requirement.

But I didn't find any node package on the web which does what I am looking for.

Any insights or any suggestions as how it can be achieved?

Thanks in advance any help would be appreciated.

Answer 1

Search for a package that computes a hash on the document, for example crypto, calculate hashes (sha256) for 2 docs and compare them. If hashes match, document content will be the same (there is still a chance of hash collision, but it depends on the hash algorytm that are you using, sha256 will give you a decent confidence that documents are identical). Check this thread for more details: Obtaining the hash of a file using the stream capabilities of crypto module (ie: without hash.update and hash.digest)

READ ALSO
Pm2 cluster + socket.io+ node.js

Pm2 cluster + socket.io+ node.js

I have my current application set up using node js, socketio and forever

24
Access variable from sync and async in nodejs

Access variable from sync and async in nodejs

I'm creating a nodejs server that has to do a few things:

52
How to handle promises in nested loop

How to handle promises in nested loop

I have an array of objects like this:

20
How to stub require('firebase-admin').auth().getUserByEmail() with sinon?

How to stub require('firebase-admin').auth().getUserByEmail() with sinon?

Could you please share some example of Sinon stub for firebase-admin authentificationThe challenge is to initialize firebase admin app for further stubs

52