On 2012-12-05, Nick Mellor <thebalance...@gmail.com> wrote:
> Hi Neil,
>
> Here's some sample data. The live data is about 300 minor
> variations on the sample data, about 20,000 lines.

Thanks, Nick.

This slight variation on my first groupby try seems to work for
the test data.

def prod_desc(s):
    prod = []
    desc = []
    for k, g in itertools.groupby(s.split(),
            key=lambda w: any(c.islower() for c in w)):
        if prod or k:
            desc.extend(g)
        else:
            prod.extend(g)
    return [' '.join(prod), ' '.join(desc)]

-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to