请问如何复杂字典转CSV?

def convert_to_csv(assignment, annotations):
# 请补全此函数
# raise NotImplementedError

if name == 'main':
# 输入数据不要改
assignment = {
'type': 'rectangle',
'properties': [{
'id': 1,
'name': '对象类型',
'items': ['小汽车', '大汽车', '人', '自行车'],
}, {
'id': 2,
'name': '是否清晰',
'items': ['是', '否'],
}, {
'id': 3,
'name': '是否完整',
'items': ['完整', '不完整'],
}],
}

annotations = [{
    'object_id': 100,
    'rectangle': {
        'x1': 100,
        'y1': 100,
        'x2': 150,
        'y2': 150,
    },
    'properties': [{
        'property_id': 1,
        'value': '自行车',
    }, {
        'property_id': 2,
        'value': '是',
    }, {
        'property_id': 3,
        'value': '完整',
    }]
}, {
    'object_id': 101,
    'rectangle': {
        'x1': 200,
        'y1': 100,
        'x2': 450,
        'y2': 150,
    },
    'properties': [{
        'property_id': 1,
        'value': '大汽车',
    }, {
        'property_id': 2,
        'value': '是',
    }, {
        'property_id': 3,
        'value': '不完整',
    }]
}, {
    'object_id': 102,
    'rectangle': {
        'x1': 100,
        'y1': 150,
        'x2': 120,
        'y2': 150,
    },
    'properties': [{
        'property_id': 3,
        'value': '完整',
    }, {
        'property_id': 1,
        'value': '大汽车',
    }, {
        'property_id': 2,
        'value': '否',
    }]
}, {
    'object_id': 103,
    'rectangle': {
        'x1': 300,
        'y1': 100,
        'x2': 400,
        'y2': 200,
    },
    'properties': [{
        'property_id': 3,
        'value': '完整',
    }, {
        'property_id': 1,
        'value': '人',
    }, {
        'property_id': 2,
        'value': '是',
    }]
}]

convert_to_csv(assignment, annotations)

用python自带的csv.DictWriter.
格式:

img

def convert_to_csv(assignment, annotations):
csv_columns = ["object_id", "对象类型"]
with open("test.csv", "w") as f:
writer = csv.DictWriter(f, fieldnames=csv_columns)
writer.writeheader()
for obj in annotations:
for proper in obj["properties"]:
if proper["property_id"] == 1:
writer.writerow({"object_id": obj["object_id"], "对象类型": proper["value"]})
result.append([obj_id, res[0][0], area])
with open(dirname + "/cc.csv", 'w', newline='', encoding='utf-8') as f:
red = csv.writer(f)
red.writerow(["id", '类型', '面积'])
red.writerows(result)
本人写的,后续写不出来了,求教!