====Retrieving Data from KPICapture====
Reading data (that you've previously [[capturing_data|written with the KPICapture class]]) is designed to be relatively easy.
First, import the library...
import kpicapture as kpi
Next, create an instance of the **KPIAccess** class. The constructor takes one parameter - the name of the [[data set|data set]] you want to read from.
KPIs = kpi.KPIAccess('daily')
//There's also an optional 2nd parameter contains the path to the folder recordings were captured to. You can use the default value if both the **writing** and **reading** reports are in the same base folder.//
Next you write the KPIs you want to record with the **CaptureValue** function. Each value should be identified with a unique name...
KPIs.GetValues(fromdate,todate)
For example, when using this in an ARDI report, you would often use...
import kpicapture as kpi
KPIs = kpi.KPIAccess('daily')
values = KPIs.GetValues(report.defaultstart,report.defaultend)
This function returns a dictionary of dates, each one of which has contains a dictionary of key-value names written on that day with the //CaptureValue// function.
{
"2029-02-02 10:00:00": {
"Total Production": "129293.7",
"Energy Usage:" 2239,
"Energy Usage When Producing": 1293,
"Energy Wasted": 946 }
}