import numpy as np M = np.loadtxt('hastighetsdata.txt', delimiter=' ') tid = M[:, 0] hastighet_km_h = M[:, 1] hastighet = hastighet_km_h/3.6 # From km/h to m/s dt = tid[1] - tid[0] # sec integral = 0.5*(hastighet[0] + hastighet[-1])*dt for i in range(1, len(hastighet)-1, 1): integral = integral + hastighet[i]*dt s = integral print('s [m] =', f'{s:.2f}')