Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #84994
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <skip.montanaro@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; 'e.g.,': 0.09; 'fashion.': 0.09; 'parsing': 0.09; 'subject:number': 0.09; 'cc:addr:python- list': 0.11; 'recognised': 0.16; 'subject:CSV': 0.16; 'weird': 0.16; 'wrote:': 0.18; 'not,': 0.20; 'feb': 0.22; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'either.': 0.24; 'format,': 0.24; "shouldn't": 0.24; 'skip': 0.24; 'cc:2**0': 0.24; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; '"",': 0.31; 'possible.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'should': 0.36; 'performance': 0.37; 'though,': 0.39; 'frank': 0.68; 'special': 0.74; '2015': 0.84 |
| 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=x/VFVkYWaajXoAUzuoK4ajbK9F9JBS7+GBAbpW06Oj8=; b=iiRRI3KwX4Vt93zfKK8pLULeEdDHhwaoHUYch1pJMCmXTzJUxeo+HKPzKmJ3W7AdUB E2VbR0P5eN9UevAXOQOTFBvo5IBA7ixrfE/5MbDi6KElYcaZOcpydZn7/NB7rO+zLIMi r5mVvfR5hxtbCF+RPpDErXuAcgBEmJC3hirrA6/T2/ZpAs9iExpo324xmjdBQjWqYlpZ yx2751dytOqzbdtUrgZmzQvTBGLNYeZtkaO3Tegsv8kZEa5NO4L/2iNmodb3aYQd3Oyb YGTCWAAGk1RdlVgGcriya19Rn9BiGZLcB9/XY991O3N5/OGWIc1Jw1mUYM8OJVBO8uQl lXJQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.182.251.138 with SMTP id zk10mr9391361obc.72.1422798622750; Sun, 01 Feb 2015 05:50:22 -0800 (PST) |
| In-Reply-To | <maki32$iav$1@ger.gmane.org> |
| References | <maki32$iav$1@ger.gmane.org> |
| Date | Sun, 1 Feb 2015 07:50:22 -0600 |
| Subject | Re: CSV and number formats |
| From | Skip Montanaro <skip.montanaro@gmail.com> |
| To | Frank Millman <frank@chagford.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | Python <python-list@python.org> |
| 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.18359.1422798626.18130.python-list@python.org> (permalink) |
| Lines | 23 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1422798626 news.xs4all.nl 2904 [2001:888:2000:d::a6]:39203 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:84994 |
Show key headers only | View raw
On Sun, Feb 1, 2015 at 12:45 AM, Frank Millman <frank@chagford.com> wrote:
> Is this a recognised format, and is there a standard way of parsing it? If
> not, I will have to special-case it, but I would prefer to avoid that if
> possible.
Doesn't look "standard" to me in any fashion. You shouldn't need to
special case it though, just
s = re.sub("^[+]0*", "", s)
e.g.,
>>> s = '+00000-21.45'
>>> t = '+0000021.45'
>>> re.sub("^[+]0*", "", s)
'-21.45'
>>> re.sub("^[+]0*", "", t)
'21.45'
That should work on all numbers, not just the weird one. Unless you
have bazillions of numbers, it shouldn't be a performance hit either.
Skip
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: CSV and number formats Skip Montanaro <skip.montanaro@gmail.com> - 2015-02-01 07:50 -0600
csiph-web