I currently have a nested dictionary object in Python that I want to loop through to essentially create an html table. I already know the basics on what to do, but need help with determining the number of rows each column should span. Let me explain more with an example:
Input:
{
"system":{
"System Apps":{
"SystemEnv":[
'App Test',
'App Memory',
'App Test']
"SystemEnv2":{
"System Test":[
'App Test']
}},
"System Memory":{
"Memeory Test":[
'Memory Func',
'Apes Test']
}
}
}
}
}
The problem lies in putting the rowspan attribute and having the correct number of rows to span. I understand that it is the number of children the parent has, but I can seem to figure out how to code it.
Also second priority, but if someone sees a more efficient way of doing this, please let me know.
for level1 in dictObj:
html += "<tr>"
html += '<td>{}</td>'.format(level1)
for level2 in dictObj[level1]:
if not first_run:
html += "<tr>"
html += '<td>{}</td>'.format(level2)
first_run = True
for level3 in dictObj[level1][level2]:
if not first_run:
html += "<tr>"
html += '<td>{}</td>'.format(level3)
first_run = True
for app in dictObj[level1][level2][level3]:
if not first_run:
html += "<tr>"
first_run = True
for test in dictObj[level1][level2][level3][app]:
if not first_run:
html += "<tr>"
html += '<td>{}</td>'.format(test)
html += '<td>{}</td>'.format(app)
html += '<td>{}</td>'.format('mb')
html += '<td>{}</td>'.format(1)
html += '</tr>'
first_run = False

