1
I have a Crawler where I get values in this format: "R$ 450,000.00".
But I need to convert these values into float and save in the database to make queries of this type: Take the values that are between 40,000.00 and 100,000.00.
1
I have a Crawler where I get values in this format: "R$ 450,000.00".
But I need to convert these values into float and save in the database to make queries of this type: Take the values that are between 40,000.00 and 100,000.00.
1
You can do it like this:
valorRaw = 'R$ 450,000.00'
valor = float(valor.split('$')[1].replace(',', '')) # 450000.0
Assuming you’re sure the values always come in that format
OR:
valorRaw = 'R$ 450,000.00'
valor = float(valor[2:].replace(',', '')) # 450000.0
[2:]
means that we want everything from index 2 ("$") and then remove the comma if there is
Browser other questions tagged python
You are not signed in. Login or sign up in order to post.
Put what you have. The part that takes the data and saves it in the database.
– Not The Real Hemingway
The answer needs to include the section related to the database, or just the conversion of types?
– Wallace Maxters
First thing you need to know: http://answall.com/q/44715/101
– Maniero