I am trying to put many numpy files to get one big numpy file, I tried to follow this link Python append multiple files in given order to one big file and this is what I did:
import matplotlib.pyplot as plt
import numpy as np
import os, sys
#Read in list of files. You might want to look into os.listdir()
path= "/home/user/Desktop/ALLMyTraces.npy/test"
#Test folder contains all my numpy file traces
traces= os.listdir(path)
# Create new File
f = open("/home/user/Desktop/ALLMyTraces.npy", "w")
for j,trace in enumerate(traces):
# Find the path of the file
filepath = os.path.join(path, trace)
# Load file
dataArray= np.load(filepath)
f.write(dataArray)
File is created, and to verify that I have the good contents, I used this code:
import numpy as np
dataArray= np.load(r'/home/user/Desktop/ALLMyTraces.npy')
print(dataArray)
This error is produced as a result:
dataArray= np.load(r'/home/user/Desktop/ALLMyTraces.npy')
File "/usr/lib/python2.7/dist-packages/numpy/lib/npyio.py", line 401, in load
"Failed to interpret file %s as a pickle" % repr(file))
IOError: Failed to interpret file '/home/user/Desktop/ALLMyTraces.npy' as a pickle
I don't know really the problem. Any help would be appreciated.