18.10.2021, 14:08
Hi
I am struggling a bit to do a replacement inside a value. What I want to do is make a log of temperatures and write this as CSV to an FTP-server at an external PC. All this works fine, but when I open the CSV in Excel, then MS in their infinite wisdom has decided that numbers containing '.' should be automatically seen as a date.
I am able to fix this myself in Excel, but in this case the users are not familiar with the use of computers, or any device connected to power, and so I must make it idiot-proof.
What I would like to do is to replace the '.' with a ',' in the value before adding it to the CSV. But I am not able to do this.
If I use string.gsub(), all characters in the value is replaced with ',', and I get values like ',,,,'. I tested a bit with string.find() to see how the '.' is read, and it seems to be some kind og 'magic character'? If I use the 'plain' parameter in string.find() I am able to find the '.'.
So, in short; how do I do this?
I am struggling a bit to do a replacement inside a value. What I want to do is make a log of temperatures and write this as CSV to an FTP-server at an external PC. All this works fine, but when I open the CSV in Excel, then MS in their infinite wisdom has decided that numbers containing '.' should be automatically seen as a date.
I am able to fix this myself in Excel, but in this case the users are not familiar with the use of computers, or any device connected to power, and so I must make it idiot-proof.
What I would like to do is to replace the '.' with a ',' in the value before adding it to the CSV. But I am not able to do this.
If I use string.gsub(), all characters in the value is replaced with ',', and I get values like ',,,,'. I tested a bit with string.find() to see how the '.' is read, and it seems to be some kind og 'magic character'? If I use the 'plain' parameter in string.find() I am able to find the '.'.
So, in short; how do I do this?
There are 10 kinds of people in the world; those who can read binary and those who don't