我用 numpy 的 genfromtxt 读取了我的数据:
import numpy as np
measurement = np.genfromtxt('measurementProfile2.txt', delimiter=None, dtype=None, skip_header=4, skip_footer=2, usecols=(3,0,2))
rows, columns = np.shape(measurement)
x=np.zeros((rows, 1), dtype=measurement.dtype)
x[:]=394
measurement = np.hstack((measurement, x))
np.savetxt('measurementProfileFormatted.txt',measurement)
这很好用。但我只想要最终输出文件中5-th
的6-th
(so n-th
) 行。根据numpy.genfromtxt.html没有参数可以做到这一点。我不想迭代数组。有没有推荐的方法来处理这个问题?