import csv
TLen=0; n=0
lines = csv.reader(open('B1.csv'))
lines.next()
for line in lines:
    TLen += int(line[1])
    n += 1
print(TLen/float(n))

This code is part of the book "Python for Bioinformatics", by Sebastian Bassi (sbassi@genesdigitales.com). Return to home page.