Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #85767
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!81.171.88.16.MISMATCH!hq-usenetpeers.eweka.nl!hq-usenetpeers.eweka.nl!bcyclone04.am1.xlned.com!bcyclone04.am1.xlned.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'parser': 0.07; 'happen,': 0.09; 'happen?': 0.09; 'subject:question': 0.10; 'cc:addr:python- list': 0.11; 'blocks': 0.16; 'dictionaries': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'parser.': 0.16; 'splitting': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'split': 0.19; 'feb': 0.22; 'otherwise,': 0.22; 'cc:addr:python.org': 0.22; 'instance,': 0.24; 'fairly': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'that.': 0.31; '(maybe': 0.31; 'basic': 0.35; 'received:google.com': 0.35; 'thanks': 0.36; 'pm,': 0.38; 'how': 0.40; 'name': 0.63; 'more': 0.64; 'here': 0.66; '2015': 0.84; 'absolutely': 0.87; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=rdEPXD5iDsSn8hbmLRSMjcn+ODKYC8vVkRiPwCQr0mI=; b=BZVpOn150c9bsVHcPW+p4DeFK9hTbspPmWqnx7tBPyQ/yFBNb+FIfmSAf9y822gZOL Rk5aW9Lv0Ms+Kn8dj5sa28ohByn1KzW8C0onn22hU3QQq1Z4sTfXhj9QjUvrxKw2TIBM pjm6th1cTUNFLuPHGqrp1+0MsfC7oi/9vMSoEAtC6T75PIpReTAsPFVt5BZHAuA10B5a R15Q1RUerxZpotQWUuxljfKo69aLIyNhCNTgaLKsaKdHlIH3DIFsjqQUkuts87kZJwfa J0D7aqub1EEl2bu1785iyid03dH6PM1Tm/3geOuWlGrkpq0vgFcwxA9bsdtmSYeygixR bI1Q== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.131.196 with SMTP id oo4mr691251igb.2.1424232965098; Tue, 17 Feb 2015 20:16:05 -0800 (PST) |
| In-Reply-To | <c41fcec3-ea9f-4cce-8f6b-0f51d8cf3912@googlegroups.com> |
| References | <c41fcec3-ea9f-4cce-8f6b-0f51d8cf3912@googlegroups.com> |
| Date | Wed, 18 Feb 2015 15:16:05 +1100 |
| Subject | Re: Noob Parsing question |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.18802.1424232968.18130.python-list@python.org> (permalink) |
| Lines | 18 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1424232968 news.xs4all.nl 2855 [2001:888:2000:d::a6]:37271 |
| X-Complaints-To | abuse@xs4all.nl |
| X-Received-Body-CRC | 986404431 |
| X-Received-Bytes | 3730 |
| Xref | csiph.com comp.lang.python:85767 |
Show key headers only | View raw
On Wed, Feb 18, 2015 at 3:07 PM, <kai.peters@gmail.com> wrote:
> Given
>
> data = '{[<a=14^b=Fred^c=45.22^><a=22^b=Joe^><a=17^c=3.20^>][<a=72^b=Soup^>]}'
>
> How can I efficiently get dictionaries for each of the data blocks framed by <> ?
>
> Thanks for any help
The question here is: What _can't_ happen? For instance, what happens
if Fred's name contains a greater-than symbol, or a caret?
If those absolutely cannot happen, your parser can be fairly
straight-forward. Just put together some basic splitting (maybe a
regex), and then split on the caret inside that. Otherwise, you may
need a more stateful parser.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Noob Parsing question kai.peters@gmail.com - 2015-02-17 20:07 -0800
Re: Noob Parsing question Chris Angelico <rosuav@gmail.com> - 2015-02-18 15:16 +1100
Re: Noob Parsing question kai.peters@gmail.com - 2015-02-17 20:35 -0800
Re: Noob Parsing question Chris Angelico <rosuav@gmail.com> - 2015-02-18 15:54 +1100
Re: Noob Parsing question kai.peters@gmail.com - 2015-02-18 08:57 -0800
csiph-web