Sorry, I still don't understand. I gather you don't literally want a "0" output for every line that does not contain a number since then your output would be, 0, 0, 16, 20, ... (I'm assuming you want to ignore the "6" in "In Field6") which does not match your sample output. Do you mean, for every "sold:" line that does not contain a number (for example "sold: <storefront>") you want a "0"? That does not match your output either since then I'd expect 16, 20, 2, 0, 0, 7, 0. Are you sure your sample output is really what you expect from the sample input? Specifically, which line of your output resulted from the "sold: 0" input line? Which output line resulted from the input line "0"?
On 10/22/2009 04:41 PM, Steve wrote: > 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 > > On Oct 22, 1:53 pm, ru...@yahoo.com wrote: >> On Oct 22, 11:27 am, Steve <zerocostprod...@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 -- http://mail.python.org/mailman/listinfo/python-list