问题描述:当利用
data = pd.read_excel(patch, header=0, sheet_name=sheet)
读取excel数据进行处理制作成npy数据集时会面临一个问题:
excel单个sheet写入的行数不允许超过65536,这个数字对于硬件工程师来说比较熟悉,是2的16次方,16位平台下,int型的最大值是32767, 而unsigned int型的最大值是65535。
所以,如果你保存的数据超过最大行数,必然得用多个sheet,或者选用txt文件格式。下面展示了如何对多个npy文件进行合并一个文件:
def Merge_npy_files():
data_1 = np.load('./data_source/data_guding0_4.npy')
data_2 = np.load('./data_source/data_guding5_6.npy')
data_3 = np.load('./data_source/data_guding7_8.npy')
label_1 = np.load('./data_source/label_gudig0_4.npy')
label_2 = np.load('./data_source/label_gudig5_6.npy')
label_3 = np.load('./data_source/label_gudig7_8.npy')
print(label_1.shape, label_2.shape, label_3.shape)
data_arr = [];labele_array=[]
data_source = [data_1,data_2,data_3]; label_source = [label_1,label_2,label_3]
for i in range(len(data_source)):
data_arr.extend(data_source[i])
labele_array.extend(label_source[i])
np.save('./data_source/data_guding0_8.npy',np.array(data_arr))
np.save('./data_source/label_guding0_8.npy',np.array(labele_array))
"""查看生成的文件"""
data_show = np.load('./data_source/data_guding0_8.npy')
label_show = np.load('./data_source/label_guding0_8.npy')
print(data_show.shape, label_show.shape)
print(label_show)
结果:(458, 36, 50) (458,)
标签:load,文件,合并,label,source,npy,np,data From: https://blog.csdn.net/2301_79275917/article/details/141460991