Print TO_CSV having comma as decimal separator

Posted By: kerplunk1899

Print TO_CSV having comma as decimal separator - 04/20/20 14:41

Hi guys,
is there a way to export data using print(TO_CSV, "...", ...) , and generating values with comma as decimal separator instead of dot?
I tried to change the option in the ini config file but it doesn't seem to work for this case.

Thanks in advance.
Posted By: AndrewAMD

Re: Print TO_CSV having comma as decimal separator - 04/20/20 16:42

I believe changing the Comma setting in the ini file only affects these exported CSV files and not TO_CSV:
https://zorro-project.com/manual/en/export.htm

So it sounds like the solution is to manually reformat the strings to European format before you issue them to TO_CSV.
Posted By: kerplunk1899

Re: Print TO_CSV having comma as decimal separator - 04/21/20 09:43

Thank you Andrew, about the ini file that's what i guessed.
Can you give me a few more details about the strings format and how to change it?
I haven't been able to find anything on the manual.
Thank you so much.
Posted By: AndrewAMD

Re: Print TO_CSV having comma as decimal separator - 04/21/20 14:17

I assume you know how to create a regular CSV with TO_CSV and how C strings work.

First, you construct your string with sprintf or strf, but with semicolons instead of commas as separators. Each var will have periods for decimal places.

Next, you iterate through each character of your string and replace each '.' with ','.

Finally, you push the string to print(TO_CSV,...).
Posted By: kerplunk1899

Re: Print TO_CSV having comma as decimal separator - 04/22/20 10:35

Ok I thought there existed some standard function.
Anyway I made it. I used strxc to replace the dots.
Thanks!!
© 2024 lite-C Forums