Bug 392165 - Join multiple cells in one field when importing CSV
Summary: Join multiple cells in one field when importing CSV
Status: RESOLVED NOT A BUG
Alias: None
Product: kmymoney
Classification: Applications
Component: importer (show other bugs)
Version: 5.0.0
Platform: Other All
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-22 08:40 UTC by Florian Lindner
Modified: 2018-03-23 07:47 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Lindner 2018-03-22 08:40:42 UTC
My bank produces CSV output like:

12345;Payer;1.000,00;Notes Field Line 1;Notes Field Line 2;Notes Field Line 3

KMyMoney is only able to import the first line (more correctly: one of the lines). It would be great, if the importer was able to join multiple cells, so that you can set the notes field to:

Notes Field Line 1 Notes Field Line 2 Notes Field Line 3

or

Notes Field Line 1
Notes Field Line 2
Notes Field Line 3

Maybe even with a configurable separator (first case: " ", second case "\n").
Comment 1 Jack 2018-03-22 18:06:49 UTC
Please clarify the example.  It is not clear which separators are literal and which are intended to indicate line feeds.  The CSV importer IS capable of combining columns into the memo field, but you are correct, each line in the csv file is considered a separate transaction.  I do think it should be able to handle line feeds within a single text field, as long as the whole column is enclosed in quotes, but I have not tested that myself.
Comment 2 Florian Lindner 2018-03-22 18:22:12 UTC
12345;Payer;1.000,00;Notes Field Line 1;Notes Field Line 2;Notes Field Line 3

this represents one transaction and is a single line, without any line breaks. As you wrote, each line represents a single transaction.

A multi-line notes field of a transaction is split to multiple colums, one for each line in the CSV field. I want KMM to join all Notes-columns into the Notes field of a KMM transaction record.

To put with python, csv represents a list of cols of a single line from a CSV file. The Notes colums are cls 3 to 5.

kmm_notes = "\n".join(csv[3:5])

You said, that KMM is capable of doing that. I just walked through the import wizard again, but found no way to accomplish that.

Thanks!
Comment 3 Florian Lindner 2018-03-22 18:26:21 UTC
EDIT:

A multi-line notes field of a transaction is split to multiple colums, one for each line in the NOTES field. I want KMM to join all Notes-columns into the Notes field of a KMM transaction record.
Comment 4 Jack 2018-03-22 18:35:15 UTC
Two questions:
1) are there three notes columns in every line in the file?  If so, good, and read on.  If not, then the different lines are of different lengths, and you would need to pre-process, in which case you could just combine them before importing.
2) I am not able to test this myself now, but have you read the manual section:
https://docs.kde.org/stable4/en/extragear-office/kmymoney/details.impexp.csv.html#idm46317016032928 which does say you can select more than one column for the memo field?  Does it not work, or did you just not try it yet?
Comment 5 Florian Lindner 2018-03-22 21:47:46 UTC
>> 1) are there three notes columns in every line in the file?  If so, good, and read on.  If not, then the different lines are of different lengths, and you would need to pre-process, in which case you could just combine them before importing. <<

It's a fixed number of cols for the notes field, yes.

>> 2) I am not able to test this myself now, but have you read the manual section:
https://docs.kde.org/stable4/en/extragear-office/kmymoney/details.impexp.csv.html#idm46317016032928 which does say you can select more than one column for the memo field?  Does it not work, or did you just not try it yet? <<

Hadn't read it, I must admit. It says:

"It is possible to select more than one column for the Memo field, by consecutive selections. Memo columns already selected are marked in the drop-down with an asterisk (*). If you select multiple columns in this way, their contents will be concatenated in the Memo field."

However, I see no way to select multiple cols. There is a dropdown field with numbers 1 to N (N is number of cols). When I make consecutive selections, I see no asterisk mark there, or anything else that marks the previous selection. I can also mark the cols in the field, but there is no way to actually select them as import source for a field. Using Ctrl key on the dropdown field also does not help to make multiple selections.
Comment 6 Jack 2018-03-22 22:12:44 UTC
Did you actually try, and finish the import?  It does work.

Once you click the dropdown and select a column number, that number is added to the label on that dropdown.  The memo dropdown seems to be different (I don't know if it's a regression - I'll have to test more, and possibly open a separate bug if necessary) it seems only to show the last column selected, but it does remember them all.  You do need to be careful that if you want any field in the memo that is also needed for another field, be sure to select it for the other field first, or else the program will make you select for both fields again, as meme is the only case where a column can be used in more than one field.
Comment 7 Florian Lindner 2018-03-23 07:47:07 UTC
You are right, should have tried first.

Also, the csvimorterrc says:

MemoCol=13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30

Still, it's very confusing, because there no user feedback for multiple selection.


I set this ticked to RESOLVED / INVALID. I also created a new bug report for the missing feedback in the UI: https://bugs.kde.org/show_bug.cgi?id=392217

Thanks for your help!