Summary: | CSV Importer detects more columns than are assigned | ||
---|---|---|---|
Product: | [Applications] kmymoney | Reporter: | NSLW <lukasz.wojnilowicz> |
Component: | importer | Assignee: | KMyMoney Devel Mailing List <kmymoney-devel> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | agander93, ralf.habacker |
Priority: | NOR | ||
Version: | git (master) | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | http://commits.kde.org/kmymoney/70b85864c91151bc68fe8fdae9c432bb93a44ba9 | Version Fixed In: | 5.0.0 |
Attachments: |
CSV Test File
Column Assignment for CSV file Warning about columns number [PATCH] CSV Importer detects more columns than are assigned |
Description
NSLW
2016-03-19 19:36:13 UTC
Created attachment 97978 [details]
CSV Test File
Created attachment 97979 [details]
Column Assignment for CSV file
Created attachment 97980 [details]
Warning about columns number
Created attachment 97981 [details] [PATCH] CSV Importer detects more columns than are assigned The place where warning is displayed is this: >>>>>>>>>>>>>>>>>>>>>> if (m_columnList.count() < m_endColumn) { if (!m_csvDialog->m_accept) { QString row = QString::number(m_row); int ret = KMessageBox::questionYesNoCancel(0, i18n("<center>Row number %1 does not have the expected number of columns.</center>" "<center>This might not be a problem, but it may be a header line.</center>" "<center>You may accept all similar items, or just this one, or cancel.</center>", row), i18n("CSV import"), KGuiItem(i18n("Accept All")), KGuiItem(i18n("Accept This")), KGuiItem(i18n("Cancel"))); if (ret == KMessageBox::Cancel) { return ret; } if (ret == KMessageBox::Yes) { m_csvDialog->m_accept = true; } } >>>>>>>>>>>>>>>>>>>>>> Where m_columnList: m_columnList = m_parse->parseLine(data); and m_endColumn = m_maxColumnCount = colCount = data.count(m_parse->m_fieldDelimiterCharList[count]) + 1; Data.count doesn't handle following lines well: 2016-01-25,MONNARI,Sprzedaż,20,"12,7",254,MON,3 It return 9 columns, while in fact it should return 8 (single value in double quotes "12,7" is treated as two columns). parseLine(data) returns correct value, which is 8 columns. Attached patch fixes this issue. Please revise it and apply to master branch. Git commit 4debce51fe4afa867db9d33baaa1a0185b031379 by Łukasz Wojniłowicz. Committed on 08/05/2016 at 07:11. Pushed by wojnilowicz into branch 'master'. Use parseLine() to determine most likely fieldDelimiter Current routine doesn't calculate columns well when FieldDelimiter=DecimalSymbol. parseLine() from csvutil.cpp does it properly. REVIEW: 127712 M +3 -3 kmymoney/plugins/csvimport/investprocessing.cpp http://commits.kde.org/kmymoney/4debce51fe4afa867db9d33baaa1a0185b031379 Git commit 70b85864c91151bc68fe8fdae9c432bb93a44ba9 by Łukasz Wojniłowicz. Committed on 08/05/2016 at 07:14. Pushed by wojnilowicz into branch 'frameworks'. Use parseLine() to determine most likely fieldDelimiter Current routine doesn't calculate columns well when FieldDelimiter=DecimalSymbol. parseLine() from csvutil.cpp does it properly. REVIEW: 127712 M +3 -3 kmymoney/plugins/csvimport/investprocessing.cpp http://commits.kde.org/kmymoney/70b85864c91151bc68fe8fdae9c432bb93a44ba9 |