Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'terry': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:string': 0.09; 'traverse': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'better?': 0.16; 'reedy': 0.16; 'subject:form': 0.16; 'subject:regex': 0.16; 'jan': 0.20; 'header:In-Reply-To:1': 0.21; 'keys': 0.23; 'values.': 0.23; 'values': 0.25; 'string': 0.26; 'object': 0.26; 'problem': 0.28; 'skip:( 40': 0.29; 'skip:1 30': 0.29; 'bit': 0.30; 'subject:How': 0.30; 'skip:( 20': 0.30; 'sets.': 0.30; 'looks': 0.31; 'header:X-Complaints-To:1': 0.32; 'to:addr:python-list': 0.33; 'external': 0.33; 'source': 0.34; 'header:User-Agent:1': 0.35; 'skip:" 10': 0.35; 'subject: ?': 0.35; 'something': 0.37; 'pretty': 0.37; 'received:org': 0.38; 'data': 0.38; 'required.': 0.38; 'subject:: ': 0.38; 'containing': 0.39; 'map': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'really': 0.40; 'skip:2 10': 0.61; 'skip:1 10': 0.63; 'simple,': 0.65; 'skip:1 20': 0.77; 'co- ordinates': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: How to form a dict out of a string by doing regex ? Date: Wed, 15 Jun 2011 14:58:07 -0400 References: <0cfd4592-75fd-48ec-884b-122b0e094078@j13g2000pro.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: rain.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 In-Reply-To: <0cfd4592-75fd-48ec-884b-122b0e094078@j13g2000pro.googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 32 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308164305 news.xs4all.nl 49182 [::ffff:82.94.164.166]:40832 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7712 On 6/15/2011 10:42 AM, Satyajit Sarangi wrote: > > > data = "GEOMETRYCOLLECTION (POINT (-8.9648437500000000 > -4.1308593750000000), POINT (2.0214843750000000 -2.6367187500000000), > POINT (-1.4062500000000000 -11.1621093750000000), POINT > (-11.9531250000000000,-10.8984375000000000), POLYGON > ((-21.6210937500000000 1.8457031250000000,2.4609375000000000 > 2.1972656250000000, -18.9843750000000000 -3.6914062500000000, > -22.6757812500000000 -3.3398437500000000, -22.1484375000000000 > -2.6367187500000000, -21.6210937500000000 > 1.8457031250000000)),LINESTRING (-11.9531250000000000 > 11.3378906250000000, 7.7343750000000000 11.5136718750000000, > 12.3046875000000000 2.5488281250000000, 12.2167968750000000 > 1.6699218750000000, 14.5019531250000000 3.9550781250000000))" > > This is my string . If this what you are given by an unchangable external source or can you get something a bit better? One object per line would make the problem pretty simple, with no regex required. > How do I traverse through it and form 3 dicts of Point , Polygon and > Linestring containing the co-ordinates ? Dicts map keys to values. I do not see any key values above. It looks like you really want three sets. -- Terry Jan Reedy