Python + IIS/ASP questions (modules, namespaces, etc)
Preston Landers
pibble at yahoo.com
Fri Dec 20 12:31:04 EST 2002
sismex01 at hebmex.com wrote in message news:<mailman.1040337986.15815.python-list at python.org>...
> Use zip to reorder your row/column data, to convert it
> into a list of tuples [ (row1), (row2), ... ]:
>
> zip(*ado.getrows()) -> list
>
> It's fairly quick.
>
> -gustavo
Ah, beautiful. I knew that builtin function would come in handy
someday.
I'm not sure about your syntax. I used this:
column_major_list = ado.GetRows()
row_major_list = apply(zip, column_major_list)
And since I really want all the strings as regular strings instead of
unicode, I also did this:
import types
def ununicode(x):
if type(x) is types.UnicodeType:
return str(x)
else:
return x
def stringify(rec):
return tuple(map(ununicode, rec))
row_major_list = map(stringify, apply(zip,ado.GetRows()))
thanks for the tip!
Preston
More information about the Python-list
mailing list