I ran the below script on some usb harddrives that I have .

I want to see if the file1.csv has repeats of the sha256 file hash in it. I also want to compare file1csv and file2.csv and pull out from the both of them the file hashes that are in both of them.

I used this python 3 program to make the csv files
Code:
#!/usr/bin/env python3
import os
import hashlib
import sys

start_path = input('Start path for file sha256sum\n')
files_dir = []
for path,dirs,files in os.walk(start_path):
    for filename in files:
        files_dir.append(os.path.join(path,filename))

# BUF_SIZE is totally arbitrary, change for your app!
BUF_SIZE = 65536  # lets read stuff in 64kb chunks!                

def pwalk():
    for x in files_dir:
        try:
            hasher = hashlib.sha256()
            with open(x, 'rb') as openfile:
                content = openfile.read(BUF_SIZE)
                hasher.update(content)
                with open('data.csv', 'a') as f:
                    print(hasher.hexdigest(), x, sep=",")#, file=f)
                    f.write(hasher.hexdigest()+','+str(x)+'\n')
        except PermissionError as permission_error:
            print(permission_error)
            with open('errors.txt', 'a') as e:
                e.write(str(permission_error)+'\n')
            pass
        except FileNotFoundError as filenotfounderror:
            pass
            print(filenotfounderror)
            with open('errors.txt', 'a') as e:
                e.write(str(filenotfounderror)+'\n')
        except OSError as oserror:
            pass
            with open('errors.txt', 'a') as e:
                e.write(str(oserror)+'\n')
            print(oserror)
    #input('Enter to close...')

pwalk()