Help with code = Extract numerical value to variable

Steve zerocostproduct at gmail.com
Thu Oct 22 18:41:23 EDT 2009


If there is a number in the line I want the number otherwise I want a
0
I don't think I can use strip because the lines have no standards


Thanks again
Steve

On Oct 22, 1:53 pm, ru... at yahoo.com wrote:
> On Oct 22, 11:27 am, Steve <zerocostprod... at gmail.com> wrote:
>
>
>
>
>
> > I have some data that I'm performing some analysis on.
> > How do I grab the numerical value if it's present and ignore
> > otherwise. So in the following example
> > I would have assign the following values to my var
> > 16
> > 20
> > 2
> > 7
> > 0
>
> > In Field6
> > Sample String data is
> > sold: 16
> > sold: 20
> > sold: 2
> > sold: 0
> > sold: <storefront>
> > 7
> > 0
> > <storefront>
> > sold
> > null
>
> So you want a list of any number that
> occurs in the file, if it occurs at the
> start of the line, or is preceded by a
> space character?  And you don't want
> any duplicates in the list?  Is the order
> of the results important?  That is, would
> a result of 16,20,2,0,7 be acceptable?
> Or how about 20,2,16,7,0?- Hide quoted text -
>
> - Show quoted text -




More information about the Python-list mailing list