On 20.04.09 02:29, Timmie wrote: > > Hello, > I asked how to change the output of a query result [1]. > As my table is rather huche and I do not want to force my users to do > vertical scrolling, I would like to transpose the SQLTABLE: > > instead of: > > header1 header2 header3 > value_row1 value_row1 value_row1 > value_row2 value_row2 value_row2 > > I would like to have: > > header1 value_row1 value_row2 > header2 value_row1 value_row2 > header3 value_row1 value_row2 > > What is the most efficient way to achieve this? > It's as if I would just pass the query result through BEAUTIFY but > with improved header and same ordering of headers as in the input > form. > > Thanks in advance, > Timmie > itertools could help if you have a big resultset:
In [1]: l = [ ....: ('h1row1','h2row1','h3row1'), ....: ('h1row2','h2row2','h3row2'), ....: ('h1row3','h2row3','h3row3') ....: ] In [2]: import itertools In [3]: for val in itertools.imap(list, itertools.izip(*l)): ...: print val ...: ...: ['h1row1', 'h1row2', 'h1row3'] ['h2row1', 'h2row2', 'h2row3'] ['h3row1', 'h3row2', 'h3row3'] Mariano --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---