petterreinholdtsen / battery-stats

Log battery charge (battery-stats-collector), show gnuplot graphs (battery-graph)
GNU General Public License v2.0
27 stars 13 forks source link

handle null values in logfiles #28

Closed anarcat closed 5 years ago

anarcat commented 6 years ago

In my experience, the CSV logfile frequently gets garbage written to it. It's unclear to me why that happens: presumably the update script does that when there's a power outage or suspend or something weird that frequently happens on laptops.

Instead of trying to figure out how the impossible happens, I figured it might be better to just deal with it better and silence those errors. I tried to do this in a better way by using an open hook, but it's actually quite difficult to do so because compressed handles don't support customizing the encoding routines the same way io.open does. Instead we monkeypatch the iterator eventually used by the CSV parser, which works in my tests.