我正在尝试放置许多 numpy 文件以获得一个大的 numpy 文件,我尝试按照这两个链接将多个 numpy 文件附加到 python 中的一个大 numpy 文件和 Python 按给定顺序将多个文件附加到一个大文件 这是我所做的:
import matplotlib.pyplot as plt
import numpy as np
import glob
import os, sys
fpath ="/home/user/Desktop/OutFileTraces.npy"
npyfilespath ="/home/user/Desktop/test"
os.chdir(npyfilespath)
with open(fpath,'wb') as f_handle:
for npfile in glob.glob("*.npy"):
# Find the path of the file
filepath = os.path.join(npyfilespath, npfile)
print filepath
# Load file
dataArray= np.load(filepath)
print dataArray
np.save(f_handle,dataArray)
dataArray= np.load(fpath)
print dataArray
Run Code Online (Sandbox Code Playgroud)
我得到的结果的一个例子:
/home/user/Desktop/Trace=96
[[ 0.01518007 0.01499514 0.01479736 ..., -0.00392216 -0.0039761
-0.00402747]]
[[-0.00824758 -0.0081808 -0.00811402 …Run Code Online (Sandbox Code Playgroud)