[Tutor] Modifying files in a directory.
qsqgeekyogdty at tiscali.co.uk
qsqgeekyogdty at tiscali.co.uk
Fri May 30 13:52:40 CEST 2008
Yes I do need to learn the basics of programming ;)
This was the first I did, was to put the modification code into the
loop, but had this error:
>>> for x in otp:
... price = float(x.contents[1].lstrip(' $'))
... x.contents[1].replaceWith('$%0.2f' % (price * 0.85))
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
IndexError: list index out of range
Then I was thinking I need to extract the actual 'cell' with the price
and then modify it.
So looked at using
actual_price = re.compile('[0-9]*(\.[0-9]*|$)')
to find the text with the price.
But then was getting too confused and maybe there is a simpler way,
which I cannot see.
Thanks
David
Guard your email - http://www.tiscali.co.uk/products/securemail/
____________________________________________________
More information about the Tutor
mailing list