Python:需要提取特定列及其值,并将其保存到Python中的文本文件中

Python:需要提取特定列及其值,并将其保存到Python中的文本文件中,python,Python,我需要在文本文件中提取column VON MISES的值,并希望提取该column名称下的值。我尝试拆分列,但无法得出结果。我是python新手。请帮助我。提前谢谢。我正在复制文本文件中我必须处理的部分。我需要最后一列值作为答案 # open file f = open ("new.txt","r") #Read whole file into data data = f.read() # Print it print data line_number=1 for num,line in

我需要在文本文件中提取column VON MISES的值,并希望提取该column名称下的值。我尝试拆分列,但无法得出结果。我是python新手。请帮助我。提前谢谢。我正在复制文本文件中我必须处理的部分。我需要最后一列值作为答案

# open file
f = open ("new.txt","r")

#Read whole file into data
data = f.read()

# Print it
print data
line_number=1
for num,line in enumerate(open("new.txt")):
        if "VON MISES" in line:
            print num+1
f.close()
你可以试试熊猫

import pandas as pd
df = pd.read_csv("new.txt", sep=',')
v_m = df['VON MISES']

out_file = open("out.txt", "w")
v_m.to_csv(out_file)

请你把这段话删掉,这样它就包含了一个小的有代表性的数据样本,然后展示你到目前为止所做的尝试。不过,您可能只需要使用pandas或csv库就可以做到这一点。