Re: Help with code = Extract numerical value to variable

2009-10-23 Thread Steve
Sorry I'm not being clear Input** sold: 16 sold: 20 sold: 2 sold: 0 sold: storefront 7 0 storefront sold null Output 16 20 2 0 0 7 0 0 0 0 -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with code = Extract numerical value to variable

2009-10-23 Thread Sion Arrowsmith
Steve zerocostprod...@gmail.com 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 What do you think strip() does? Read http://docs.python.org/library/stdtypes.html#str.lstrip *carefully*

Help with code = Extract numerical value to variable

2009-10-23 Thread Dave Angel
Steve wrote: Sorry I'm not being clear Input** sold: 16 sold: 20 sold: 2 sold: 0 sold: storefront 7 0 storefront sold null Output 16 20 2 0 0 7 0 0 0 0 Since you're looking for only digits, simply make a string containing all characters that aren't digits. Now, loop

Re: Help with code = Extract numerical value to variable

2009-10-23 Thread rurpy
On 10/23/2009 05:16 AM, Dave Angel wrote: Steve wrote: Sorry I'm not being clear Input** sold: 16 sold: 20 sold: 2 sold: 0 sold: storefront 7 0 storefront sold null Output 16 20 2 0 0 7 0 0 0 0 Since you're looking for only digits, simply make a string

Re: Help with code = Extract numerical value to variable

2009-10-22 Thread Peter Pearson
On Thu, 22 Oct 2009 10:27:57 -0700 (PDT), Steve 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

Re: Help with code = Extract numerical value to variable

2009-10-22 Thread rurpy
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

Re: Help with code = Extract numerical value to variable

2009-10-22 Thread Steve
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...@yahoo.com wrote: On Oct 22, 11:27 am, Steve zerocostprod...@gmail.com wrote: I have some data that I'm

Re: Help with code = Extract numerical value to variable

2009-10-22 Thread rurpy
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: