我有一个 4 列 x 180.000 行的数据文件。我想根据第 3 列中的值在特定间隔内的标准,即最小值 < 第 3 列值 < 最大值,选择要保存到新文件的整行数据。
有什么办法吗?
最佳答案
使用 csv
module读写,然后过滤:
with open(inputfilename, 'rb') as inputfile, open(outputfile, 'wb') as outputfile:
reader = csv.reader(inputfile)
writer = csv.writer(outputfile)
for row in reader:
if minval <= int(row[2]) <= maxval:
writer.writerow(row)
关于python - 如何选择数据行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16251996/