Hi I'm trying to solve a problem. I have a json list of products, ex:
[{
"id": 5677240,
"name": "Cønjuntø de Pænelæs æntiæderentes ¢øm 05 Peçæs Pæris",
"quantity": 21,
"price": "192.84",
"category": "Panelas"
},
{
"id": 9628920,
"name": "Lava & Seca 10,2 Kg Sæmsung E¢ø ßußßle ßræn¢æ ¢øm 09 Prøgræmæs de Lævægem",
"quantity": 57,
"price": 3719.70,
"category": "Eletrodomésticos"
}]
But I basically need the "price" to be float like the second product. I have a large list of these products
(Ignore the weird characters I managed to fix it with help from a teacher.) I converted them to python object using this
import json
with open('br2.json', 'r', encoding='utf8') as json_data:
data = json.load(json_data)
I've tried something like this but it doesn't work
for product in data:
product["price"] = product["price"].replace(",", "")
I want to replace the values that are in string with the "" to float
thanks in advance sorry I'm new to python so I don't understand much