Error running ei_json_to_csv.ipynb by Shawn Hymel

Question/Issue: Hi I am currently attempting to run the ei_json_to_csv to convert my dataset from JSON format to CSV.However, I am getting this error and I do not understand how to fix it. Kindly can you help

KeyError Traceback (most recent call last)
in <cell line: 4>()
12
13 # Parse the sample rate, header, and data
—> 14 sample_rate = data[‘payload’][‘interval_ms’]
15 for heading in data[‘payload’][‘sensors’]:
16 header.append(heading[‘name’])

KeyError: ‘payload’

Project ID:

Context/Use case:

{
“protected”: {
“ver”: “v1”,
“alg”: “HS256”,
“iat”: 1564128599
},
“signature”: “b0ee0572a1984b93b6bc56e6576e2cbbd6bccd65d0c356e26b31bbc9a48210c6”,
“payload”: {
“device_name”: “ac:87:a3:0a:2d:1b”,
“device_type”: “DISCO-L475VG-IOT01A”,
“interval_ms”: 10,
“sensors”: [
{ “name”: “accX”, “units”: “m/s2” },
{ “name”: “accY”, “units”: “m/s2” },
{ “name”: “accZ”, “units”: “m/s2” }
],
“values”: [
[ -9.81, 0.03, 1.21 ],
[ -9.83, 0.04, 1.27 ],
[ -9.12, 0.03, 1.23 ],
[ -9.14, 0.01, 1.25 ]
]
}
}

Are you sure you have “payload” data in your JSON file (see above), also check Data acquisition format specification

1 Like