How can I drop a trailing zero from a text string that will be written to a csv file. For example: "0.10" to "0.1"
mt4 always remove 0 at back of every floating number if you use php to extact the data for processing use number_format function
[example]
if (strlen(substr(strrchr($value,"."), 1)) == 5) { $high = number_format($value,5); }
elseif (strlen(substr(strrchr($value,"."), 1)) == 4) { $high = number_format($value,4); }
elseif (strlen(substr(strrchr($value,"."), 1)) == 3) { $high = number_format($value,3); }
mt4 always remove 0 at back of every floating number if you use php to extact the data for processing use number_format function
[example]
if (strlen(substr(strrchr($value,"."), 1)) == 5) { $high = number_format($value,5); }
elseif (strlen(substr(strrchr($value,"."), 1)) == 4) { $high = number_format($value,4); }
elseif (strlen(substr(strrchr($value,"."), 1)) == 3) { $high = number_format($value,3); }
I apologize, I should have mentioned this is mql5. StringSubstr also completely removes "0". Thank you for your help.
I've tried that, but a string like "0" is also deleted.
- Why do you care?
- Convert your number to a string. While the last digit is zero, reduce the length. Return the substring. Show
us your attempt (using the CODE button)
and state the nature of your problem.
No free help
For special cases use if-statements.
I've already search the documentation. Nothing explains how to export to csv the same way as Excel. Thank you for your ideas.
- Why do you care?
- Convert your number to a string. While the last digit is zero, reduce the length. Return the substring. Show
us your attempt (using the CODE button)
and state the nature of your problem.
No free help
1. Why do I care? Because I don't want a bad csv file that crashes python with pandas code. Excel does it automatically, but I don't want to import every mt5 exported csv file into Excel and then have Excel export it correctly.
2. I have already done that. As I mentioned, it does not work if the only character is "0" (I don't want that one dropped). I've been reading the documentation and have not found the answer to my specific problem. I've also tried the various code page options but without avail.
Finally, I have no problem posting my code here, but as you said, "No free help." I'll do it myself.
P.S. Years ago, these forums were full of people trying to help each other. Those were the days.
To anyone else that actually tried to help, a sincere thank you.
1. Why do I care? Because I don't want a bad csv file that crashes python with pandas code. Excel does it automatically, but I don't want to import every mt5 exported csv file into Excel and then have Excel export it correctly.
2. I have already done that. As I mentioned, it does not work if the only character is "0" (I don't want that one dropped). I've been reading the documentation and have not found the answer to my specific problem. I've also tried the various code page options but without avail.
Finally, I have no problem posting my code here, but as you said, "No free help." I'll do it myself.
P.S. Years ago, these forums were full of people trying to help each other. Those were the days.
To anyone else that actually tried to help, a sincere thank you.
You got help but you didn't listen. Stop criticising people trying to help you and start to be open minded.
Who have you ever helped here ?
It's a false issue, there is absolutely no need to remove this 0, it doesn't make sense.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
How can I drop a trailing zero from a text string (in mql5) that will be written to a csv file. For example: "0.10" to "0.1" Basically, I want to save the mql5 to the csv in the same format that Excel exports to csv.