Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:text': 0.05; 'correct.': 0.07; 'string': 0.09; 'lines.': 0.09; 'subject:into': 0.09; 'cc:addr:python-list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'oyster': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'trying': 0.19; 'not,': 0.20; 'cc:addr:python.org': 0.22; 'certainly': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'sets': 0.30; 'message-id:@mail.gmail.com': 0.30; 'lines': 0.31; 'that.': 0.31; '25,': 0.31; 'file': 0.32; 'text': 0.33; 'fri,': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'so,': 0.37; 'list': 0.37; 'pm,': 0.38; 'consists': 0.60; 'tell': 0.60; "you're": 0.61; 'subject:this': 0.83; 'splitted': 0.84; 'items,': 0.91; '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=KlBphRZhrF1OBORdj7mISmU7gxWduKZ1DnD2OgR1iv8=; b=Be1mTw7f34+8ksAQ/cSnTfAE77j70Cc4UJ0C/dnUQJriWXpV/YskhYjHtaqhdaGQtF ctWz2ohzk9s4pbDvhFLmvBnfrtrN0Lzeb8hcGz254GWNKT4rhmGaSRGQrU4SbelHDZC3 BTw5SEtxD9xSNr54MGOB6TB3wpJW2QAnBYuOtQiHZGsyskvQ4ts+XXrGNkGVVnb1kEvP SCG/23j8ilVF58YRyLNMxO3WaL3ql5FGv0rLILVqAwSfxmLzpwuHhd1lD1DL+TnmmO9V Hw04TvIEIl1l2O3H3G7dGtQUPdz30n8SxM2y8os7P570IYFCDTlLDiVOM9AYZjWfTZyc uyLQ== MIME-Version: 1.0 X-Received: by 10.58.1.97 with SMTP id 1mr6950216vel.23.1398432718097; Fri, 25 Apr 2014 06:31:58 -0700 (PDT) In-Reply-To: References: Date: Fri, 25 Apr 2014 23:31:58 +1000 Subject: Re: how to split this kind of text into sections From: Chris Angelico Cc: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1398432720 news.xs4all.nl 2948 [2001:888:2000:d::a6]:51667 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70590 On Fri, Apr 25, 2014 at 11:07 PM, oyster wrote: > the above text should be splitted as a LIST with 3 items, and I also need to > know the KEY for LIST is ['I am section', 'let's continue', 'I am using']: It's not perfectly clear, but I think I have some idea of what you're trying to do. Let me restate what I think you want, and you can tell be if it's correct. You have a file which consists of a number of lines. Some of those lines begin with the string "I am section", others begin "let's continue", and others begin "I am using". You want to collect those three sets of lines; inside each collection, every line will have that same prefix. Is that correct? If so, we can certainly help you with that. If not, please clarify. :) ChrisA