views:

21

answers:

0

I have what I call a catalogue, a dictonary like this:

fields = ("property1", "property2")

catalogue = { 0.3: {
                   100: [ {"property1": 0.3, "property2": 100, "value": 1000},
                          {"property1": 0.3, "property2": 100, "value": 2000},
                          {"property1": 0.3, "property2": 100, "value": 5000}, ],
                   200: [ {"property1": 0.3, "property2": 200, "value": 3000},
                          {"property1": 0.3, "property2": 200, "value": 2000},
                          {"property1": 0.3, "property2": 200, "value": 7000}, ],
                   },
              0.5: {
                   150: [ {"property1": 0.5, "property2": 150, "value": 3200},
                          {"property1": 0.5, "property2": 150, "value": 2300},
                          {"property1": 0.5, "property2": 150, "value": 7400}, ],
                   250: [ {"property1": 0.5, "property2": 250, "value": 3300},
                          {"property1": 0.5, "property2": 250, "value": 2400},
                          {"property1": 0.5, "property2": 250, "value": 7600}, ],
                    },
             }

I want to produce an html table like this:

<table>
<tr> 
  <th>property1</th> 
  <th>property2</th>
</tr>
<tr> 
  <td rowspan="2">0.3</td> 
  <td>100</td> 
</tr>
<tr>
  <td>200</td>
</tr>
<tr>
  <td rowspan="2">0.5</td>
  <td>150</td>
</tr>
<tr>
  <td>250</td>
</tr>
</table>

to produce a table like this:

----------------------
property1 | property2
----------------------
          |  100
0.3       |  
          |  200
----------|-----------
          |  150
0.5       |
          |  250
----------------------

take in mind that the catalogue can be more complicated, here I have only 2 properties, but in general they can be more.