Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change a dot to a comma #9

Open
Robisy opened this issue Jan 25, 2023 · 2 comments
Open

change a dot to a comma #9

Robisy opened this issue Jan 25, 2023 · 2 comments

Comments

@Robisy
Copy link

Robisy commented Jan 25, 2023

6E33D1B3-7604-4379-9213-B9B9EF501AE4
Hello, i export tempearture by bme280 to google sheet. How can I change dots to commas? from 21.23 to 21,23

P.s.
changing the zone in the sheet doesn't help :)

Regards

@StorageB
Copy link
Owner

StorageB commented Jan 25, 2023

Because the ESP8266 code uses commas to separate the multiple values sent to Google Sheets, it is easier to make this change in the Google Script code after the string of values are received from the ESP8266 and are separated and stored as separate variables.

First, in your Google Sheets spreadsheet go to File > Settings and verify that the Locale is set to a region that uses that number format (such as Germany).

Using the example code, let's assume the "value2" variable is the number you wish to convert. In the Google Script code, add this line of code after value2 is declared and the value from the ESP8266 is assigned to it:

value2 = value2.toString().replace(".", ",");

Screenshot from 2023-01-25 16-01-35

This converts the value received from the ESP8266 to a string, and replaces the decimal point with a comma before it gets published to the spreadsheet.

Lastly, you may need to make sure the column containing the values is formatted correctly. In Google Sheets highlight the entire column, and go to Format > Number, and select the Number format.

Google Sheets should now recognize this value as a number formatted as 0.000,00.

Screenshot from 2023-01-25 16-19-27

Note that when making changes to the Google Scripts code, you will need to click Save then Deploy > New deployment for any new changes to take effect. You will be given a new Deployment ID that you will have to update in the ESP8266 code each time (each new deployment is given a new Deployment ID).

@lucasromeiro
Copy link

6E33D1B3-7604-4379-9213-B9B9EF501AE4 Hello, i export tempearture by bme280 to google sheet. How can I change dots to commas? from 21.23 to 21,23

P.s. changing the zone in the sheet doesn't help :)

Regards

Hello, do you use function doGET or doPOST?

If you use doPOST, can u post here you code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants