Saving 1D Numpy Array to a CSV file. Storing a NumPy array in CSV format. Krunal Lathiya is an Information Technology Engineer. array ([[ 1 , 2 , 4 ],[ 1 , 3 , 9 ],[ 1 , 4 , 16 ]]) # Saving the array np . Just execute the following code. Parameters fname filename or file handle. Default is ‘latin1’. After running the example, you will see the new file in the directory with the name ‘npfile.npy‘. This function takes a filename and array as arguments and saves the array into CSV format. Parameters: fname: filename or file handle. In real life our data often lives in the file system, hence these methods … If the file is a file object, then the filename is unchanged. Now, we will read the file using the np.load() function and print the content of the npy file in the console. In the above example, we saved the numpy array in npfile.npy file. np.savetxt ( "array_1d_with_hf.csv" , [array_1d],delimiter= "," ,fmt= "%d" ,header= "This is header" ,footer= "This is footer") When you are using numpy.savetxt() function to save numy array into a text file, you my get this error: TypeError: Mismatch between array dtype ('