I found a solution, I don't know if it is the good one, but works enough 
for me.

My real data structure is slightly different about the above example:

db.define_table('ctd',
    Field('station'),
    Field('parameter'),
    Field('value','integer'))

It contains oceanographic information about sea water.
This is a recordset example:

ctd.id station param. ctd.value
1 1 depth 5
2 1 depth 10
3 1 depth 15
4 1 depth 20
5 1 depth 25
6 1 C 44
7 1 C 56
8 1 C 66
9 1 C 62
10 1 C 77
11 1 q 13
12 1 q 22
13 1 q 41
14 1 q 63
15 1 q 52


This is the controller I used:
def ctd():   
   r=[]
   fields=[]
   for row in  db(db.ctd.station==1).select(db.ctd.parameter,distinct=True):
      d=[]
      fields.append(row.parameter)
      for col in db(db.ctd.station==1 and 
db.ctd.parameter==row.parameter).select(db.ctd.value):
         d.append(col.value)
      r.append(d)
   return dict(fields=fields, rows=r)

And this one is the view (default/ctd.html)
{{extend 'layout.html'}}
<table>
    <thead>
        <tr>
        {{for f in fields:}}
            {{=TH(f)}}    
        {{pass}}
        </tr>
    </thead>
    <tbody>
        {{for j in range(0,len(rows[0])):}}
        <tr>
           {{for i in range(0,len(rows)):}}
               {{=TD(rows[i][j])}}
            {{pass}}
        </tr>
        {{pass}}
    </tbody>
</table>

The result is what I wanted:

C depth q
44 5 13
56 10 22
66 15 41
62 20 63
77 25 52


If someone knows a better way... please tell us!

-- 



Reply via email to