Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #94715
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <joel.goldstick@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.054 |
| X-Spam-Evidence | '*H*': 0.89; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'python': 0.10; 'mathematics': 0.15; 'subject: \n ': 0.15; '97m': 0.16; 'whitespace.': 0.16; 'wrote:': 0.16; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'pipe': 0.22; 'split': 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.24; 'chris': 0.26; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'looks': 0.29; 'job:': 0.29; "i'm": 0.30; 'url:mailman': 0.30; "i'd": 0.31; 'another': 0.32; 'url:python': 0.33; 'lets': 0.33; 'symbol': 0.33; 'url:listinfo': 0.34; 'case,': 0.34; 'tue,': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'url:org': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'turn': 0.37; 'anything': 0.38; 'or,': 0.38; 'does': 0.39; 'url:mail': 0.40; 'jul': 0.72; 'sounds': 0.76; 'chrisa': 0.84; 'differently:': 0.84; 'victor': 0.84; 'joel': 0.91 |
| 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:to :cc:content-type; bh=w7T4wEj1E3y4hwKaC/il/kJSCCjMc6jWqebZ1A7jzCI=; b=Y9eh0YyL/VBpq2rWt20b18TDagaA7myiM3Fqe9NJK1VGDMyGH5O97H42sK2d+8AdiZ 5T2cRHJgZtFbFRhdNUxS4hfR8s2AetSd+M1soa5Z0BMcWCVepuRJ4RYiVSGe51XGPV0I bkKEiLbbpYcfqW6McaiW66rhmH52zX3FUmrSmdEwwzqzXChnZYHN0NZYBYV20avDlZ+p ICmlPj/BbY6VKdZk/Pdq+vJChBnuXiOAfZw6ChS8AgOdjWPSNCck+I3lcLq+VbCraI5X 1QlSwsvIlmlxoLY+twuSeURCZVnRmX70ZYTBHptmHXX62/fBl5U5GtSo2l0Skxq/Ueng UKxg== |
| MIME-Version | 1.0 |
| X-Received | by 10.107.163.16 with SMTP id m16mr56150658ioe.31.1438133304868; Tue, 28 Jul 2015 18:28:24 -0700 (PDT) |
| In-Reply-To | <CAPTjJmoMV39Sq4PpZ4uAV0bCptrWzggvinDys00Nb6=gS-eEpA@mail.gmail.com> |
| References | <fed7bab5-db18-45c3-9ba2-4b7fbfa80602@googlegroups.com> <CAPTjJmoMV39Sq4PpZ4uAV0bCptrWzggvinDys00Nb6=gS-eEpA@mail.gmail.com> |
| Date | Tue, 28 Jul 2015 21:28:24 -0400 |
| Subject | Re: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? |
| From | Joel Goldstick <joel.goldstick@gmail.com> |
| To | 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.20+ |
| 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.1056.1438137388.3674.python-list@python.org> (permalink) |
| Lines | 29 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1438137388 news.xs4all.nl 2824 [2001:888:2000:d::a6]:52816 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:94715 |
Show key headers only | View raw
+1 Chris
On Tue, Jul 28, 2015 at 8:08 PM, Chris Angelico <rosuav@gmail.com> wrote:
> On Tue, Jul 28, 2015 at 11:55 PM, Victor Hooi <victorhooi@gmail.com> wrote:
>> I have a line that looks like this:
>>
>> 14 *0 330 *0 760 411|0 0 770g 1544g 117g 1414 computedshopcartdb:103.5% 0 30|0 0|1 19m 97m 1538 ComputedCartRS PRI 09:40:26
>>
>> I'd like to split this line on multiple separators - in this case, consecutive whitespace, as well as the pipe symbol (|).
>
> Correct me if I'm misanalyzing this, but it sounds to me like a simple
> transform-then-split would do the job:
>
> f.replace("|"," ").split()
>
> Turn those pipe characters into spaces, then split on whitespace. Or,
> reading it differently: Declare that pipe is another form of
> whitespace, then split on whitespace. Python lets you declare anything
> you like, same as mathematics does :)
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
--
Joel Goldstick
http://joelgoldstick.com
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? Victor Hooi <victorhooi@gmail.com> - 2015-07-28 06:55 -0700
Re: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? m <mvoicem@gmail.com> - 2015-07-28 15:59 +0200
Re: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? Victor Hooi <victorhooi@gmail.com> - 2015-07-28 07:09 -0700
Re: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? MRAB <python@mrabarnett.plus.com> - 2015-07-28 15:30 +0100
Re: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? Chris Angelico <rosuav@gmail.com> - 2015-07-29 10:08 +1000
Re: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? Rustom Mody <rustompmody@gmail.com> - 2015-07-28 19:41 -0700
Re: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? Joel Goldstick <joel.goldstick@gmail.com> - 2015-07-28 21:28 -0400
csiph-web