Thanks

Actually the number I am getting it is from slicing from a long text
line. I need to slice 10 characters from that line but no string only
numeric numbers. When I am slicing 10 characters those A, c, O is coming
at the end. 

Thanks


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Dennis Lee Bieber
Sent: Wednesday, September 10, 2008 3:45 PM
To: python-list@python.org
Subject: Re: removing text string

On Wed, 10 Sep 2008 11:22:16 -0400, "Ahmed, Shakir" <[EMAIL PROTECTED]>
declaimed the following in comp.lang.python:

> I need to remove text string from the list of the numbers mentioned
> below:
> 
> 080829-7_A
> 070529-5_c
> 080824-7_O
> 070405_6_p
> 
        ?       Is that last one an error that is supposed to be
...5-6_, not
...5_6_ ?

1)              If the required data is fixed width, just slice it

        out = inp[:8]

2)              If the data is variable width but has a fixed delimiter,
find
the delimiter position and then slice (this is the reason for my
question above -- this method) OR just split on the delimiter and take
the part you need.

        out = inp.split("_")[0]

3)              If the data is more complex (again if that last line
with two _
is supposed to be trimmed after the second, and the first turned into a
-) you will need to fully define the parsing rules of the data.
-- 
        Wulfraed        Dennis Lee Bieber               KD6MOG
        [EMAIL PROTECTED]               [EMAIL PROTECTED]
                HTTP://wlfraed.home.netcom.com/
        (Bestiaria Support Staff:               [EMAIL PROTECTED])
                HTTP://www.bestiaria.com/
--
http://mail.python.org/mailman/listinfo/python-list

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to