Good use for itertools.dropwhile and itertools.takewhile

Neil Cerutti neilc at norwich.edu
Wed Dec 5 21:13:41 CET 2012


On 2012-12-05, Nick Mellor <thebalancepro at gmail.com> wrote:
> Neil,
>
> Further down the data, found another edge case:
>
> "Spring ONION from QLD"
>
> Following the spec, the whole line should be description
> (description starts at first word that is not all caps.) This
> case breaks the latest groupby.

A-ha! I did check your samples for the case of an empty product
name and not find any started to think it couldn't happen.

Change

   if prod or k:

to

   if desc or prod or k:

If this data file gets any weirder, let me know. ;)

-- 
Neil Cerutti



More information about the Python-list mailing list