Python Forum

Full Version: Split gps files based on time (text splitting)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all.
I have a gps file that has the following format. Someone said that it seems to be json file but I am not sure.

Segment of the file looks like that :
´
2020-10-12 14:30:23: {"class":"VERSION","release":"3.20","rev":"3.20","proto_major":3,"proto_minor":14}
2020-10-12 14:30:23: {"class":"DEVICES","devices":[{"class":"DEVICE","path":"/dev/ttyS0","driver":"NMEA0183","activated":"2020-10-12T14:30:22.966Z","flags":1,"native":0,"bps":4800,"parity":"N","stopbits":1,"cycle":1.00}]}
2020-10-12 14:30:23: {"class":"WATCH","enable":true,"json":false,"nmea":true,"raw":0,"scaled":false,"timing":false,"split24":false,"pps":false}
2020-10-12 14:30:23: $GPRMC,143023,A,4915.0754,N,01113.6519,E,000.0,000.0,121020,002.5,E*70
2020-10-12 14:30:23: $GPGGA,143023,4915.0754,N,01113.6519,E,1,09,1.0,401.1,M,46.4,M,,*49
2020-10-12 14:30:23: $GPGSA,A,3,02,04,05,06,07,09,16,29,30,,,,2.0,1.0,1.8*3C
2020-10-12 14:30:23: $GPGSV,3,1,09,02,39,275,38,04,25,075,33,05,26,305,30,06,33,215,32*75
2020-10-12 14:30:23: $GPGSV,3,2,09,07,65,162,33,09,64,067,41,16,18,051,33,29,05,331,20*78
2020-10-12 14:30:23: $GPGSV,3,3,09,30,38,195,33*45
as you can see all line segments start with a timestamp. Is it possible to parse such file and pick only lines that fall inside those time periods. If yes can you suggest me one two function so I can get started?

Thanks a lot.
Regards
Alex