Re: head for grouped data - looking for best practice

2005-03-12 Thread Harald Massa
Steve, > Why don't you just pass a slice to itemgetter? py> for key, bereich in groupby(eingabe, itemgetter(slice(0, 2))): WHOW, that is great! that makes it really simple, just have to structure the SQL to make a real "cut first, serve first" structure. Thanks to all who helped! also the "f

Re: head for grouped data - looking for best practice

2005-03-12 Thread Steven Bethard
Harald Massa wrote: def getdoublekey(row): return row[0:2] for key, bereich in groupby(eingabe,getdoublekey): print "Area:",key for data in bereich: print "--data--", data[2:] Why don't you just pass a slice to itemgetter? py> eingabe=[ ... ("Stuttgart","70197","Fernsehturm","20

Re: head for grouped data - looking for best practice

2005-03-12 Thread Peter Otten
Harald Massa wrote: > def getdoublekey(row): > return row[0:2] > > for key, bereich in groupby(eingabe,getdoublekey): > print "Area:",key > for data in bereich: > print "--data--", data[2:] > > which indeed leeds to the expected result, while looking less "hacky" .. > on the

Re: head for grouped data - looking for best practice

2005-03-12 Thread Diez B. Roggisch
> which indeed leeds to the expected result, while looking less "hacky" .. > on the other hand side, that "getdoublekey" ist not very flexible; when > doing the same with 3 Columns forming the head information, I have to > define the next function... Make getdoublekey something like this (untested

head for grouped data - looking for best practice

2005-03-12 Thread Harald Massa
Old, very old informatical problem: I want to "print" grouped data with head information, that is: eingabe=[ ("Stuttgart","70197","Fernsehturm","20"), ("Stuttgart","70197","Brotmuseum","123"), ("Stuttgart","70197","Porsche","123123"), ("Leipzig","01491","Messe","91822"), ("Leipzig","01491","Scha