Какой-то код для начала. Он создает новую книгу и записывает значения в строки.
import json
import openpyxl
data = [
{
"id": 1993966466,
"deficiencyArea": {
"id": 270424374,
"area": "18",
"areaDescription": "Labour conditions",
"subArea": "4",
"subAreaDescription": "Health protection, medical care, social security",
"ismRelated": False
},
"defectiveItem": {
"id": 273058079,
"code": "18417",
"description": "Anchoring devices",
"restricted": False
},
"defaultDescription": {
"id": 742,
"code": "1047",
"description": "Not ready for use"
},
"groundForDetention": False,
"recognizedOrganizationRelated": False,
"accidentalDamage": False,
"ismRelated": False
},
{
"id": 1993966468,
"deficiencyArea": {
"id": 156,
"area": "07",
"areaDescription": "Fire safety",
"subArea": "1",
"subAreaDescription": None,
"ismRelated": False
},
"defectiveItem": {
"id": 1358,
"code": "07105",
"description": "Fire doors/openings in fire-resisting divisions",
"restricted": False
},
"defaultDescription": {
"id": 470,
"code": "1011",
"description": "Not as required"
},
"groundForDetention": False,
"recognizedOrganizationRelated": False,
"accidentalDamage": False,
"ismRelated": False
}
]
# create workbook
wb = openpyxl.Workbook()
ws = wb.worksheets[0]
row1 = ["id","areaDescription","subAreaDescription","description","restricted","description"]
for i in range(1,7):
ws.cell(1,i).value = row1[i-1]
i = 1
for rec in data:
area = rec["deficiencyArea"]
item = rec["defectiveItem"]
desc = rec["defaultDescription"]
i += 1
ws.cell(i,1).value = rec["id"]
ws.cell(i,2).value = area["areaDescription"]
ws.cell(i,3).value = area["subAreaDescription"]
ws.cell(i,4).value = item["description"]
ws.cell(i,5).value = item["restricted"]
ws.cell(i,6).value = desc["description"]
filename = "result.xlsx"
wb.save(filename=filename)
print("{} created with {} rows".format(filename,i-1))