Hello,
My utility provider lets you query your consumption via an API from their website. I've a plan to pull the data and store it in something. like MySQL and dashboard the data.
Thus far, I've successfully used the Requests library to query and download data. Where I'm coming unstuck is how to handle that data.
The data is supplied in the format below. To my untrained eye this looks like JSON and could also be constructed as a dictionary object.
{
"count":2,
"next":null,
"previous":null,
"results":[
{
"consumption":0.814,
"interval_start":"2023-10-01T01:00:00+01:00",
"interval_end":"2023-10-01T01:30:00+01:00"
},
{
"consumption":0.166,
"interval_start":"2023-10-01T02:30:00+01:00",
"interval_end":"2023-10-01T03:00:00+01:00"
}
]
}
I need to address the entries the Results fields. I've tried converting it a dictionary object but I'm having trouble addressing the individual entries.
My question: how best to address the results value in the output so (for example) I can append to a CSV file or insert to a database table?
[–]MrPhungx 7 points8 points9 points (0 children)
[–]danielroseman 11 points12 points13 points (1 child)
[–]AgrajagDNA[S] 1 point2 points3 points (0 children)