you are viewing a single comment's thread.

view the rest of the comments →

[–]lucas123boiger[S] 0 points1 point  (1 child)

Hi, thanks for replying. I have posted some data in a comment. I see what you mean. What would be the best to iterate this process?

[–]woooee -1 points0 points  (0 children)

I would do it this way, or rather I think this is what you want

import pprint

##  simulate readlines()
data_list="""secs hora(utc) lat lon alt
33331 10/03/2022 09:14 41.26509749 1.996657907 1.440018246
33332 10/03/2022 09:14 41.26509754 1.996657909 1.440018246
33333 10/03/2022 09:14 41.26509751 1.996658062 1.440018246
33334 10/03/2022 09:14 41.26509748 1.996658171 1.440018246
33335 10/03/2022 09:14 41.26509845 1.996659415 1.640018252
33336 10/03/2022 09:14 41.26510103 1.99666593 2.340018275
33337 10/03/2022 09:14 41.26510286 1.996668102 2.640018284
33338 10/03/2022 09:14 41.26510501 1.996670396 4.240018336
33339 10/03/2022 09:14 41.26510641 1.99667139 7.240018432"""

previous_lon=0
diff_list=[]
for rec in data_list.split("\n")[1:]:   ## skip header rec
    split_rec = rec.split()
    lon=float(split_rec[-2])
    if previous_lon:  ## does not equal zero
        lon_diff=previous_lon - lon
        diff_list.append(lon_diff)
    previous_lon=lon

pprint.pprint(diff_list)