I have read data from particular API using the following Python lines
import requests
import json
# read all Measurement from one sensor for several days.
r = requests.get('https://wastemanagement.post-iot.lu/measurement/measurements?source=83512 pageSize=1000000000&dateFrom=2019-10-26&dateTo=2019-10-28', auth=('xxxxx', 'xxxxx'))
text=r.text # data is stored in json format
This is an example of the output but the actual output contains several lines: Actual output can be downloaded from here actual output
enter code here
Valid JSON (RFC 8259)
Formatted JSON Data
{
"next":"https://wastemanagement.post-iot.lu/measurement/measurements?dateTo=2019-10-28&
pageSize=2000&source=83512&dateFrom=2019-10-26¤tPage=2",
"self":"https://wastemanagement.post-iot.lu/measurement/measurements?dateTo=2019-10-28&
pageSize=2000&source=83512&dateFrom=2019-10-26¤tPage=1",
"statistics":{
"totalPages":null,
"currentPage":1,
"pageSize":2000
},
"measurements":[
{
"self":"https://wastemanagement.post-iot.lu/measurement/measurements/108451",
"time":"2019-10-26T00:00:06.494Z",
"id":"108451",
"source":{
"self":"https://wastemanagement.post-iot.lu/inventory/managedObjects/83512",
"id":"83512"
},
"type":"c8y_Measurement",
"battery":{
"percent":{
"unit":"%",
"value":98
}
}
},
{
"self":"https://wastemanagement.post-iot.lu/measurement/measurements/108452",
"time":"2019-10-26T00:00:06.538Z",
"id":"108452",
"source":{
"self":"https://wastemanagement.post-iot.lu/inventory/managedObjects/83512",
"id":"83512"
},
"type":"TemperatureMeasurement",
"c8y_TemperatureMeasurement":{
"T":{
"unit":"C",
"value":23
}
}
},
{
"self":"https://wastemanagement.post-iot.lu/measurement/measurements/108537",
"time":"2019-10-26T00:00:06.577Z",
"id":"108537",
"source":{
"self":"https://wastemanagement.post-iot.lu/inventory/managedObjects/83512",
"id":"83512"
},
"type":"c8y_Measurement",
"c8y_DistanceMeasurement":{
"distance":{
"unit":"cm",
"value":21
}
}
},
the attached image show the output in the (text)
I have tried to convert the JSON format (Which is stored in text) to pandas DataFrame using the following code but doesnt work
data = json.loads(text)
I would like to convert JSON format to pandas DataFrame, this Dataframe should contain five columns (id, battery,T or Temperature, time, and distance) and several rows