import hashlib # works for all type of data # check if files are different def compare_files(f1, f2): with open(f1, 'rb') as t1, open(f2, 'rb') as t2: fileA_hash = hashlib.sha256(t1.read()).digest() fileB_hash = hashlib.sha256(t2.read()).digest() if fileA_hash == fileB_hash: print("Files are the same: no new data") return True else: print("Files are not the same: new data to process") return False """with open(f1, 'r') as t1, open(f2, 'r') as t2: # open again to read data not binary fileA = t1.readlines() fileB = t2.readlines() with open(out_path+'update.csv', 'w') as outFile: for line in fileB: if line not in fileA: print("different line detected") outFile.write(line)"""