I have a crawler where I get values in this format: "$ 450,000.00."
But I need to convert these values to float and save in the database to make queries of this type: Get the values that are between 40,000.00 and 100,000.00.
I have a crawler where I get values in this format: "$ 450,000.00."
But I need to convert these values to float and save in the database to make queries of this type: Get the values that are between 40,000.00 and 100,000.00.
You can do this:
valorRaw = 'R$ 450,000.00'
valor = float(valor.split('$')[1].replace(',', '')) # 450000.0
Assuming you're sure values always come in that format
OU:
valorRaw = 'R$ 450,000.00'
valor = float(valor[2:].replace(',', '')) # 450000.0
[2:]
means that we want everything from index 2 ("$") and then we remove the comma if there is