My file is correct, KMM displays correct preview of CSV file, but I get warning about incorrect column number (see attachment) Reproducible: Always Steps to Reproduce: 1. file->import csv 2. choose investment 3. create new profile 4. open "test file.csv" and assign columns to values (see attachment) 5. FieldDelimiter to comma 6. TextDelimiter to double quotes 7. DecimalSymbol to comma 8. ImportCSV Actual Results: Get warning that file doesn't have expected number of columns. Expected Results: No warning at all. FieldDelimiter=DecimalSymbol !
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