import pylab as pb #too messy a = [float(i) for i in open('EKG.txt', 'r').read().split(',')] det = [int(i<-2500) for i in a] d = [i-j if i-j>0 else 0 for i, j in zip(det[0:-1] , det[1:])] pb.plot(a) pb.plot([i*5000 for i in d]) print ('dlugosc zapisu', len(d)/100.) print ('ilosc uderzen', (sum(d))) print( 'tetno', sum(d)*60./(len(d)*1.0/100.)) pb.show()