2 回答

TA贡献1946条经验 获得超3个赞
我认为您的错误在开头的 for 循环中。你有,for line in ins1但你永远不会line在循环内使用。在您的循环中,您还使用了之前未定义的number_string和data。
以下是从 txt 文件中提取数据的方法。
with open("bijlage.txt", "r") as ff:
ll = ff.readlines() #extract a list, each element is a line of the file
data = []
for line in ll[1:]: #excluding the first line wich is an header
d = line.split(';')[5] #split each line in a list using semicolon as a separator and keep the element with index 5
data.append(float(d.replace(',', '.'))) #substituting the comma with the dot in the string and convert it to a float
print data #data is a list with all the numbers you want
您应该能够从这里计算均值和标准差。
添加回答
举报