I can't perform any math operations on these values that I had exported. I'm using xlwt
library to do this. Any way to convert these values in the format so that I can be able to perform math operations on it.
Asked
Active
Viewed 1,247 times
3 Answers
3
float('3629,473.237'.replace(',', ''))

Wasif
- 14,755
- 3
- 14
- 34

MaxTechniche
- 141
- 5
-
2Please don't use curly quotes use straight ones – Wasif Nov 22 '20 at 06:46
-
@WasifHasan I’m on iPhone, I don’t know how. – MaxTechniche Nov 22 '20 at 16:49
-
I have edited the answer for you. – Wasif Nov 22 '20 at 16:51
1
You can replace the commas, they make no sense except readablity
n = float("3629,473.237".replace(",",""))
To re-add commas as string, you can use format strings:
print("{:,}".format(n))
There are f-strings in python 3.6+
print(f"{n:,}")

Wasif
- 14,755
- 3
- 14
- 34
-
I need this commas as well. It is an requirement from our client. Any other solution? – Marcus Nov 22 '20 at 06:49
-
0
No; you'll have to remove the comma manually.
float("123,000.12".replace(',',''))
If you have consistent data, you might as well remove all the commas and convert the result.

Wasif
- 14,755
- 3
- 14
- 34

sultan ayubi
- 1
- 1