Reading Campbell Scientifc Inc. (CSI) Loggerfiles with Python (or IDL)

TL;DR;Summary

Read Campbell Scientific Loggerfiles (TOB1/TOB3/TOA5/CSIXML(Python only)) directly with the code available in my GitHub repo

Background & Motivation

Campbell Scientific Inc. sells a wide range of data loggers for all kinds of purposes – be it computational power, low power usage or connectivity. To save storage and ensure data integrity, they also have their own binary format – the (dreaded) TOB3 files. They are what you can restore from an SD card if it becomes corrupted and you use software to restore the data.

Now, these you can usually convert via their proprietary software LoggerNet into TOB1/TOA5 datafiles where TOB1 is a simpler binary format and TOA5 an ASCII format. There is even an XML format available. Usually, TOA5 is the way to go as data storage is at this point no longer such a restriction, XML is harder to parse than ASCII and binary is even worse to simply read. However, depending on the actual size (and we did/do actually sample a ceilometer with such a logger, making quite large TOB3 files), converting is time-consuming and often a manual process unless you are downloading the files directly via LoggerNet.

As I had to go through the trouble of restoring TOB3 files and reading them (first in IDL, then in Python) I wrote functionality for each file type that makes them easily accessible. You won’t get out a pandas dataframe as I wanted to keep the dependencies as small as possible (i.e. standard lib) but the conversion is straightforward as you get a nested list with the format [timestamp, recordnumber, datarecords ...] where timestamp is a datetime object.

Hopefully, this helps someone that had to deal with CSI files or will have to.