Peter S
Peter S

Reputation: 575

Convert csv File into Round Robin Database

I am logging Temp and Humidity from a DHT22 sensor on a Raspberry Pi 2 running latest Jessie.

I did not know about the possibilities of RRDtool when starting the project so I chose to log everything in a .csv file called DataLogger.csv. The logging script is written an python 3 executed every Minute with cron. The Format looks like this:

2016-04-02 21:23    16.5    45.9
2016-04-02 21:24    16.5    45.9
2016-04-02 21:25    16.5    46.0

So it goes %Y-%M-%D %H:%M \t Temperature \t Humidity

I am thinking about additionally log everything in Round Robin as well so my question is:

  1. Can I load the .csv rows into a RRDtool and
  2. Can I use update from RRDtool to check the .csv file every Minute and update the Database

or do I habe to log the Data directly into the Database?

Upvotes: 0

Views: 1703

Answers (2)

Steve Shipway
Steve Shipway

Reputation: 4027

As Tobi said, you will need to write your own script to parse your CSV fail and load the data into your new RRD file, as RRDtool does not itself have a function to do this.

You will need to work out the correct design for your RRD in advance; looking at your data, it seems to be every second and so you will need a 1sec Interval and probably your first RRA will need to be a 1cdp=1pdp.

You should also remember that data can only be added with time increasing; so, you can never add a datapoint for a timepoint earlier than the last update time. Thus you would need to add your CSV data oldset point first and so on.

Upvotes: 1

Tobi Oetiker
Tobi Oetiker

Reputation: 5450

RRDtool does not interact itself with csv files. But you can write a little script to read your existing csv files and feed them into RRDtool. Note that one call to the update function can take multiple datapoints in the timestamp:temp:hum format.

Once your existing data has been added to the rrd database, just add a call to the update function whenever you write to the csv file.

Upvotes: 2

Related Questions