Trying to format a string value

I am scraping the natural gas price from a site and I get the value in DKK that reads “11,9”. To make further calculations I need to convert the string to a value that is “11.9”. In other words I need to change the string “,” into “.”.
I am using multiscraper and my code is:

- resource: https://www.gasprisguiden.dk/329.html
  scan_interval: 31000
  sensor:
    unique_id: total12_gas_price_m3
    name: Total Gas Price in M3
    select: "body > div.container-fluid.main-container > table > tbody > tr:nth-child(3) > td:nth-child(5)"
    unit_of_measurement: "DKK"
    value_template: '{{ value[:-6] }}'

I suppose I have to format the value_template line, but how?

value_template: "{{ value[:-6].replace(',','.') }}"

Thank you so much. It works perfectly!
PS: Are there any places where I could have found that information myself?

1 Like

Here’s one but there are many other python references:

1 Like