In [11]:
#test measurements
import datetime as dt

In [4]:
raw = []

with open('sensordata','r') as sd:
    raw = sd.readlines()

In [5]:
for i in range(10):
    print(raw[i])


2017-07-06 21:56:54 T23.19P1009.15H50.10

2017-07-06 22:12:12 T22.75P1009.00H50.31

2017-07-06 22:27:44 T22.33P1009.09H50.35

2017-07-06 22:43:08 T22.10P1009.19H49.88

2017-07-06 22:58:55 T21.93P1009.01H49.48

2017-07-06 23:14:55 T21.81P1008.79H49.65

2017-07-06 23:31:08 T21.66P1008.89H50.92

2017-07-06 23:46:28 T21.58P1008.71H52.08

2017-07-07 00:02:05 T21.49P1008.56H53.97

2017-07-07 00:17:34 T21.41P1008.75H55.06


In [9]:
#split data
split = list(map(lambda x: x.split(' '),raw))

In [10]:
for i in range(10):
    print(split[i])


['2017-07-06', '21:56:54', 'T23.19P1009.15H50.10\n']
['2017-07-06', '22:12:12', 'T22.75P1009.00H50.31\n']
['2017-07-06', '22:27:44', 'T22.33P1009.09H50.35\n']
['2017-07-06', '22:43:08', 'T22.10P1009.19H49.88\n']
['2017-07-06', '22:58:55', 'T21.93P1009.01H49.48\n']
['2017-07-06', '23:14:55', 'T21.81P1008.79H49.65\n']
['2017-07-06', '23:31:08', 'T21.66P1008.89H50.92\n']
['2017-07-06', '23:46:28', 'T21.58P1008.71H52.08\n']
['2017-07-07', '00:02:05', 'T21.49P1008.56H53.97\n']
['2017-07-07', '00:17:34', 'T21.41P1008.75H55.06\n']

In [37]:
mtimes = map(lambda x: x[0] + ' ' + x[1],split)#measurement times
mdtimes = map(lambda x: dt.datetime.strptime(x,'%Y-%m-%d %H:%M:%S'),mtimes)#times as datetime objects

In [38]:
prev = next(mdtimes)
for current in mdtimes:
    print((current - prev).total_seconds() / 60)
    prev = current


15.3
15.533333333333333
15.4
15.783333333333333
16.0
16.216666666666665
15.333333333333334
15.616666666666667
15.483333333333333
15.533333333333333
15.583333333333334
15.95
15.5
15.6
15.883333333333333
15.533333333333333
15.483333333333333
15.966666666666667
15.916666666666666
15.95
16.0
15.9
15.983333333333333
15.45
15.55
15.55
15.95
15.983333333333333
15.516666666666667
15.616666666666667
15.6
15.966666666666667
16.383333333333333
15.5
15.533333333333333
15.6
15.95
15.55
15.466666666666667
15.983333333333333
15.966666666666667
15.5
15.533333333333333
15.95
15.933333333333334
15.916666666666666
15.583333333333334
16.35
15.516666666666667
15.533333333333333
15.533333333333333
15.933333333333334
15.6
15.516666666666667
15.916666666666666
15.533333333333333
16.083333333333332
15.516666666666667
15.966666666666667
15.533333333333333

In [ ]: