0

OK so I have an altimeter unit that is reading the altitude, pressure and temperature every 1.5 seconds. It takes these readings and stores them in conveniently named .txt files. It also prints them on the screen as well. The one that it on the screen is the "current" reading. Nice and easy!

My problem is that I want to do a small bit of processing where I take the most recently saved bit of data and compare it to the "current" reading. This might look something like:

Current = 100m altitude.

Previous = 105m altitude.

Difference = -5m Altitude.

Just as a note, the current data is being displayed already, the current and previous data as above wouldn't really need to be shown, just the bottom "difference" section.

From here I have already set up a dictionary to sort this into it's own classification of calm, medium and heavy weather. But I can't figure out how to read the last line of a .txt document and compare it to my most recent result.

Ninja edit: I forgot to mention I'm using a raspberry Pi 4 4gb ram model. My sensor data is being collected over I2C.

In terms of code I haven't really tried anything because I'm not really sure even what commands I'd be using. I've got no real experience in doing this kind of data working. I followed some basic guides like (stackoverflow.com/questions/7167008/…) from a simple google but even if I have the previous reading, I have no idea how to do anything with that. I thought it might have to be some kind of variable maybe? That changes every time a new number gets added to the .txt? Then I would just do some kind of difference equation?

Couldn't attatch the actual .txt. Here is a sample of what the file looks like.

12:00:56 16/04/2020 Altitude : 86.8 m 12:01:04 16/04/2020 Altitude : 87.0 m

12:01:11 16/04/2020 Altitude : 86.7 m 12:01:19 16/04/2020 Altitude : 86.9 m

12:01:27 16/04/2020 Altitude : 86.9 m 12:01:34 16/04/2020 Altitude : 86.7 m

Alessio
  • 3,404
  • 19
  • 35
  • 48
Paolo
  • 1
  • 1
  • What have you tried so far? See [How to create a minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) – RMPR Apr 16 '20 at 10:04
  • In terms of code I haven't really tried anything because I'm not really sure even what commands I'd be using. I've got no real experience in doing this kind of data working. I followed some basic guides like (https://stackoverflow.com/questions/7167008/efficiently-finding-the-last-line-in-a-text-file) from a simple google but even if I have the previous reading, I have no idea how to do anything with that. I thought it might have to be some kind of variable maybe? That changes every time a new number gets added to the .txt? Then I would just do some kind of difference equation? – Paolo Apr 16 '20 at 10:54
  • You should post a sample txt file. – RMPR Apr 16 '20 at 10:57
  • Couldn't attatch the actual .txt. Here is a sample of what the file looks like. 12:00:56 16/04/2020 Altitude : 86.8 m 12:01:04 16/04/2020 Altitude : 87.0 m 12:01:11 16/04/2020 Altitude : 86.7 m 12:01:19 16/04/2020 Altitude : 86.9 m 12:01:27 16/04/2020 Altitude : 86.9 m 12:01:34 16/04/2020 Altitude : 86.7 m – Paolo Apr 16 '20 at 11:05
  • Update your question with this information – RMPR Apr 16 '20 at 11:10
  • How are named your .txt files? What OS is your raspberry using? – RMPR Apr 16 '20 at 12:21

0 Answers0