|
大佬们,现在用了一个 npz 打包,速度很快,我用的 Python ,代码如下:
@app.route('/get_data_bin', methods=['GET'])
def get_data_bin():
start = time.time()
data_2d, data_1d = readDataFile(r'C:\wxy\吕博士\data\data_2025-04-17 10-56-00_count2000_pointBytes20784.dat')
# 将两个数组打包成 .npz 压缩文件到内存
buf = io.BytesIO()
np.savez_compressed(buf, data=data_2d.astype(np.float32), timestamps=data_1d.astype(np.float64))
buf.seek(0)
print("打包耗时:", round(time.time() - start, 2), "秒")
return send_file(
buf,
as_attachment=True,
download_name="data.npz",
mimetype="application/octet-stream"
) |