Hi Neil, Here's some sample data. The live data is about 300 minor variations on the sample data, about 20,000 lines.
Nick Notes: 1. Whitespace is only used for word boundaries. Surplus whitespace is not significant and can be stripped 2. Retain punctuation and parentheses 3. Product is zero or more words in all caps at start of line 4. Description is zero or more words beginning with first word that is not all caps. Description continues to the end of the line 5. Return tuple of strings (product, description) Sample data --- BEANS hand picked BEETROOT certified organic BOK CHOY (bunch) BROCCOLI Mornington Peninsula BRUSSEL SPROUTS CABBAGE green CABBAGE Red CAPSICUM RED CARROTS CARROTS loose CARROTS juicing, certified organic CARROTS Trentham, large seconds, certified organic CARROTS Trentham, firsts, certified organic CAULIFLOWER CELERY Mornington Peninsula IPM grower CELERY Mornington Peninsula IPM grower CUCUMBER EGGPLANT FENNEL GARLIC (from Argentina) GINGER fresh uncured KALE (bunch) KOHL RABI certified organic LEEKS LETTUCE iceberg MUSHROOM cup or flat MUSHROOM Swiss brown ONION brown ONION red ONION spring (bunch) PARSNIP, certified organic POTATOES certified organic POTATOES Sebago POTATOES Desiree POTATOES Bullarto chemical free POTATOES Dutch Cream POTATOES Nicola POTATOES Pontiac POTATOES Otway Red POTATOES teardrop PUMPKIN certified organic SCHALLOTS brown SNOW PEAS SPINACH I'll try to get certified organic (bunch) SWEET POTATO gold certified organic SWEET POTATO red small SWEDE certified organic TOMATOES Qld TURMERIC fresh certified organic ZUCCHINI APPLES Harcourt Pink Lady, Fuji, Granny Smith APPLES Harcourt 2 kg bags, Pink Lady or Fuji (bag) AVOCADOS AVOCADOS certified organic, seconds BANANAS Qld, organic GRAPEFRUIT GRAPES crimson seedless KIWI FRUIT Qld certified organic LEMONS LIMES MANDARINS ORANGES Navel PEARS Beurre Bosc Harcourt new season PEARS Packham, Harcourt new season SULTANAS 350g pre-packed bags EGGS Melita free range, Barker's Creek BASIL (bunch) CORIANDER (bunch) DILL (bunch) MINT (bunch) PARSLEY (bunch) On Thursday, 6 December 2012 00:29:13 UTC+11, Neil Cerutti wrote: > On 2012-12-05, Nick Mellor <thebalance...@gmail.com> wrote: > > > Hi Terry, > > > > > > For my money, and especially in your versions, despite several > > > expert solutions using other features, itertools has it. It > > > seems to me to need less nutting out than the other approaches. > > > It's short, robust, has a minimum of symbols, uses simple > > > expressions and is not overly clever. If we could just get used > > > to using takewhile. > > > > The main reason most of the solutions posted failed is lack of > > complete specification to work with while sumultaneously trying > > to make as tiny and simplistic a solution as possible. > > > > I'm struggling with the empty description bug right now. ;) > > > > -- > > Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list