Search code examples
pythonexport-to-csv

Save Image dataset into CSV


I have an Image dataset consisting of 90k images of size [64,64,3]. I have done some preprocessing to the images, which takes a lot of time if I have to do it from scratch. Now, how do I store these images/ images as a numpy array for shape[90000,64,64,3] into a csv file, as integers, along with their labels?

Is there any other way (other file type) to store this data?

P.S: I tried np.savetxt but, when I read back the data, I get strings with dots and a lot of the values are lost.

Thank you.


Solution

  • Found it!!

    We can use

    np.save()
    

    to save the array in a .npy format and load the file using

    np.load()
    

    Also, multiple numpy arrays can be saved using

    np.savez()
    

    and

    np.savez_compressed()
    

    to save them in .npz and a compressed .npz format. COOL