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:
>> 7
>> 0
>>
>> sold
>> null
>>
>> Output
>> 16
>> 20
>> 2
>> 0
>> 0
>> 7
>> 0
>> 0
>> 0
>> 0
>
> Since you're looking for onl
Steve wrote:
Sorry I'm not being clear
Input**
sold: 16
sold: 20
sold: 2
sold: 0
sold:
7
0
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 through the file and use
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
What do you think strip() does? Read
http://docs.python.org/library/stdtypes.html#str.lstrip
*carefully* (help(''.lstrip) is slightly ambiguou
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:
7
0
s
Sorry I'm not being clear
Input**
sold: 16
sold: 20
sold: 2
sold: 0
sold:
7
0
sold
null
Output
16
20
2
0
0
7
0
0
0
0
--
http://mail.python.org/mailman/listinfo/python-list
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
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 wrote:
>
>
>
>
>
> > I have some data that I'm performing some ana
On Oct 22, 11:27 am, 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
> Sample Strin
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