FrancescoCastaldi commented on issue #45660:
URL: https://github.com/apache/superset/issues/45660#issuecomment-6524017799

   ### Root Cause Analysis & Solution
   
   When exporting chart data to CSV or Excel:
   1. `DataFrame.to_csv` defaults to `.` as decimal separator and `,` as column 
delimiter.
   2. In European locales (such as German `de`), localized versions of Excel 
use `;` as column delimiter and `,` as decimal separator. Consequently, values 
like `3.5` are parsed as dates (`03. Mai`), and floating-point values without 
formatting precision can expose raw IEEE-754 representations (e.g. 
`19.799999999999997`).
   3. In `superset/utils/csv.py`, `format_decimal` previously converted 
`Decimal` objects to fixed-point strings using period without accepting custom 
decimal separators.
   
   #### Solution & Recommended Configuration
   1. In `superset_config.py`, configure `CSV_EXPORT` with localized delimiters 
and float format:
   ```python
   CSV_EXPORT = {
       "encoding": "utf-8-sig",
       "sep": ";",
       "decimal": ",",
       "float_format": "%.10g",
   }
   ```
   2. In `superset/utils/csv.py`, `format_decimal(value, 
decimal_separator=".")` now accepts an optional `decimal_separator` argument, 
allowing custom separators to be respected. In addition, `df_to_escaped_csv` 
enforces `\n` line terminators uniformly across platforms.
   
   Verified with unit tests in `tests/unit_tests/utils/csv_tests.py` and 
committed to branch `fix/community-unanswered-issues` (commit `ddf3da2aa1b`) at 
https://github.com/FrancescoCastaldi/superset/tree/fix/community-unanswered-issues.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to