Bug 496700 - CSV export generates incorrect csv files if a comma is used as a decimal separator
Summary: CSV export generates incorrect csv files if a comma is used as a decimal sepa...
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: exporter (show other bugs)
Version: git (master)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-26 12:20 UTC by Ralf Habacker
Modified: 2024-11-26 20:48 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.2
Sentry Crash Report:


Attachments
test file (1.45 KB, application/x-kmymoney)
2024-11-26 12:20 UTC, Ralf Habacker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Habacker 2024-11-26 12:20:28 UTC
Created attachment 176132 [details]
test file

STEPS TO REPRODUCE
1.  start kmymoney from master branch
2.  open appended file
3.  open report "Copy of Investment Performance by Account (Only Owned)"
4. export report to CSV
5. Inspect generated file

OBSERVED RESULT
The generated file is exported with the following content and ',' used as column delimiter.

"Report: Copy of Investment Performance by Account (Only Owned)"
01.01.2024 to 26.11.2024
Account,Buy Value,Dividends reinvested,Market Value,Annualised return,Return On Investment
"Shares"
"BHP"," -22.475,00"," 0,00"," 24.245,00",2,67%,7,88%
Total Shares," -22.475,00"," 0,00"," 24.245,00",2,67%,7,88%
Grand Total," -22.475,00"," 0,00"," 24.245,00",2,67%,7,88%

The problem with this file is that it contains more than the expected columns when using a language setting with comma as decimal separator, e.g. the number 2.67% is imported as two columns with the values “2” and “67%”.

EXPECTED RESULT
The export should output numbers with quotation marks to prevent this problem. 

SOFTWARE/OS VERSIONS
Operating System: openSUSE Leap 15.5
KDE Plasma Version: 5.27.9
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8
Comment 1 Jack 2024-11-26 16:19:50 UTC
Into what software are you importing this file?  Do the quoted values import correctly?  If using Excel or LibreOffice, I would expect quoted values to be imported as text, not as numbers, so I don't believe that quoting the percent values will do what you want.  My suspicion is that the program will need to use a field separator other than comma if comma is the decimal separator.  However, if the currency values do import properly for you, then quoting the percent values shouldn't be too difficult.
Comment 2 Ralf Habacker 2024-11-26 19:16:43 UTC
 (In reply to Jack from comment #1)
> Into what software are you importing this file? 
libreoffice
>  Do the quoted values import correctly?  
yes
> If using Excel or LibreOffice, I would expect quoted values to be imported as text, not as numbers, so I don't believe that quoting the
> percent values will do what you want.  My suspicion is that the program will
> need to use a field separator other than comma if comma is the decimal
> separator. 

This would then have to be changed in the kmymoney source code.

>  However, if the currency values do import properly for you, 

yes, tested with Libreoffice, they are shown as numbers in the cell format setting page.

> then quoting the percent values shouldn't be too difficult.

Yes, this must be fixed in the kmymoney csv report generator.
Comment 3 Ralf Habacker 2024-11-26 20:31:17 UTC
Git commit 3cc5907900e463dfaff4ca37d75284fe607c4080 by Ralf Habacker.
Committed on 26/11/2024 at 20:28.
Pushed by habacker into branch 'master'.

Output percentage values in double quotation marks in CVS exports

If percentages contain decimal places, the decimal point may conflict
with the comma currently used as a column separator, depending on the
language setting. This is resolved with this commit.
FIXED-IN:5.2

M  +1    -1    kmymoney/plugins/views/reports/core/listtable.cpp

https://invent.kde.org/office/kmymoney/-/commit/3cc5907900e463dfaff4ca37d75284fe607c4080
Comment 4 Ralf Habacker 2024-11-26 20:48:51 UTC
Git commit a2188afe0a03be150446e14e2d2ce151ee35edb0 by Ralf Habacker.
Committed on 26/11/2024 at 20:48.
Pushed by habacker into branch 'master'.

Adjust expected values in report test containing percent values

M  +1    -1    kmymoney/plugins/views/reports/core/tests/data/test-infotable-report-infotable-Darlehen-Informationen-_angepasst_.csv

https://invent.kde.org/office/kmymoney/-/commit/a2188afe0a03be150446e14e2d2ce151ee35edb0