Objective: Extract Currency Value (not Date) from given file.
Content of file: [["1234567890","Your previous month point is QR 5,200.33.Your
current month point is QR 1,15,200.33, Last Year total point earned QR
5589965.26 and point lost in game is QR -11520 your this year subscription will
expire on 19-04-2013. 9. Back"]]
What I have done so far:
def read_file():
fp = open('D:\\ReadData2.txt', 'rb')
content = fp.read()
data = eval(content)
l1 = ["%s" % x[1] for x in data]
return l1
def check_currency(l2):
import re
for i in range(l2.__len__()):
newstr2 = l2[i]
val_currency = []
val_currency.extend(re.findall(r'([+-]?\d+(?:\,\d+)*?\d+(?:\.\d+)?)',newstr2))
print " List %s " % val_currency
for i in range(len(val_currency)):
val2 = val_currency[i]
remove_commas = re.compile(r',(?=\d+)*?')
val3 = remove_commas.sub('', val2)
print val3
if __name__=="__main__":main()
Ouput of check_currency:
>List ['5,200.33', '1,15,200.33', '5589965.26', '-11520', '19', '-04', '-2013']
Expected Ouput of check_currency:
List ['5,200.33', '1,15,200.33', '5589965.26', '-11520']
Problem with output: I am getting date in currency value which it should not.
What alteration should I do in my regex to complete???
Thank You
Regards
Dharmjeet Kumar
This e-mail and all material transmitted with it are for the use of the
intended recipient(s) ONLY and contains confidential and/or privileged
information. If you are not the intended recipient, please contact the sender
by reply e-mail and destroy all copies and the original message. Any
unauthorized review, use, disclosure, dissemination, forwarding, printing or
copying of this email or any action taken pursuant to the contents of the
present e-mail is strictly prohibited and is unlawful. The recipient
acknowledges that Comviva Technologies Limited or its management or directors,
are unable to exercise control or ensure the integrity over /of the contents of
the information contained in e-mail. Any views expressed herein are those of
the individual sender only and no binding nature of the contents shall be
implied or assumed unless the sender does so expressly with due authority of
Comviva Technologies Limited. E-mail and any contents transmitted with it are
prone to viruses and related defects despite all efforts to avoid such by
Comviva Technologies Limited.
_______________________________________________
python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32