Skip to content

Instantly share code, notes, and snippets.

@fandrefh
Created March 7, 2016 23:40
Show Gist options
  • Select an option

  • Save fandrefh/9b9c0282968a0d3b4424 to your computer and use it in GitHub Desktop.

Select an option

Save fandrefh/9b9c0282968a0d3b4424 to your computer and use it in GitHub Desktop.
fhand = open('mbox-short.txt')
count = 0
total = 0 # acumuladora/totalizadora
for line in fhand:
line = line.rstrip()
if line.startswith('X-DSPAM-Confidence: '):
count = count + 1
limit = line.find(':')
line = float(line[limit+1:])
total = total + line # cálculo, o valor atual mais o valor de cada linha
print (line)
print ('Count:',count)
print ('Sum:',total)
print ('Average:',(total / count))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment