python 2.7 - to get the integer value after : and subtract it from the next value -


i have text file , need integer each line 246012 , subtract next line's integer using python

[739:246012] phythrad: dspmsgq  received: msg type is[130] , sfnsf [14996] [sfn:937 sf:4] [739:246050] start of macthread:receved msg type[47] [739:247021] phythrad: dspmsgq  received: msg type is[130] , sfnsf [14997] [sfn:937 sf:5] [739:247059] start of macthread:receved msg type[47] [739:248013] phythrad: dspmsgq  received: msg type is[130] , sfnsf [14998] [sfn:937 sf:6] [739:248053] start of macthread:receved msg type[47] 

this should trick:

with open('myfile.txt') a:     = a.readlines()     nums = [int(lines[lines.find(':')+1:lines.find(']')]) lines in a]     result = [y - x x, y in zip(nums, nums[1:])]  print result 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -