import imagehash
from PIL import Image
import glob
import numpy as np
image_list = []
for filename in glob.glob('/home/folder/*.jpg'):
im=Image.open(filename)
image_list.append(im)
hash = imagehash.average_hash(im)
print(hash)
list_rows = [[hash]]
np.savetxt("numpy_test.csv", list_rows, delimiter=",", fmt='% s')
how to save all the hashes generated into the same csv file and not only the last one
Here, you're overwriting your
list_rows
variable for every step in the loop. You should append to the list instead, and then write the content of the list to your csv.PS: Try not to override builtin (like hash) that may be dangerous !