2 回答

TA貢獻(xiàn)1946條經(jīng)驗(yàn) 獲得超3個(gè)贊
我認(rèn)為您的錯(cuò)誤在開頭的 for 循環(huán)中。你有,for line in ins1但你永遠(yuǎn)不會(huì)line在循環(huán)內(nèi)使用。在您的循環(huán)中,您還使用了之前未定義的number_string和data。
以下是從 txt 文件中提取數(shù)據(jù)的方法。
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
您應(yīng)該能夠從這里計(jì)算均值和標(biāo)準(zhǔn)差。
添加回答
舉報(bào)