import chardet
def read_data():
with open('haberman.data', 'r') as infile, open('haberman.csv', 'w', encoding='utf-8') as outfile:
survival, total = [0]*4, [0]*4
for line in infile:
age, year, axi, outcome = (int(word.strip()) for word in line.split(','))
if outcome == 2: outcome = 0
# print(age, year+1900, axi, outcome, file = outfile, sep = ',')
if age<40:
if outcome:
survival[0] += 1
total[0] += 1
elif age < 50:
if outcome:
survival[1] += 1
total[1] += 1
elif age < 60:
if outcome:
survival[2] += 1
total[2] += 1
else:
if outcome:
survival[3] += 1
total[3] += 1
for survivals, totals in zip(survival, total):
print(survivals/totals*100)