larry.bates at websafe.com
Fri Sep 9 21:32:53 CEST 2005
The first question is why do you need tuples?
But this works:
tlines=tuple([tuple(x) for x in reader])
Luis P. Mendes wrote:
> I'm trying to solve this problem:
> suppose I'm reading a csv file and want to create a tuple of all those
> rows and values, like ((row1value1, row1value2, row1value3),(row2value1,
> row2value2, row2value3),..., (rowNvalue1, rowNvalue2, rowNvalue3))
> I haven't found the way to do it just using tuples. How can I do it?
> Nevertheless, I can solve it like this:
> for row in reader:
> ~ elem = (row,row,row)
> ~ a.append(elem)
> which will result in a list of tuples: [(row1value1, row1value2,
> row1value3),(row2value1, row2value2, row2value3),..., (rowNvalue1,
> rowNvalue2, rowNvalue3)]
> Then, I get what I want with tuple(a).
> Luis P. Mendes
More information about the Python-list