Interestingly, this just showed up on Python List:

On 10/06/2016 05:09 AM, Frank Millman wrote:

I have used itertools.groupby before, and I love it. I used it
 to process a csv file and 'break' on change of a particular
 field. It worked very well.

Now I want to use it to process a database table. I can select
 the rows in the desired sequence with no problem. However, I
 am using asyncio, so I am reading the rows asynchronously.

My 'reader' class has __aiter__() and __anext__() defined.

If I pass the reader to groupby, I get the error message
 'object is not iterable'.

Before I spend hours trying to figure it out, can anyone
 confirm if this is doable at all, or is groupby not designed
 for this.

Is adapting the groupby recipe in the docs and adding async support (and thus 
duplicating code) the only way at this point?  Will there be a better way in 
the future?

--
~Ethan~
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to