This forum has been archived. All content is frozen. Please use KDE Discuss instead.

CSV Importer and date format

Tags: None
(comma "," separated)
gordmcfee
Registered Member
Posts
5
Karma
0

CSV Importer and date format

Mon Apr 18, 2022 6:30 pm
I am having an issue importing a CSV file into KMyMoney. I'm using the File -> Import process. It all goes well until I get to the final page and it announces that the date format is wrong. The date format in KMyMoney is yyyy-mm-dd and the date format in the csv file is also yyyy-mm-dd. I can't understand what the error could be. Has anyone seen this kind of behaviour an does anyone know what might be causing this? The importer ddefailts to m d y (no punctuation), so I change it to y-m-d. Could that have anything to do with it?

Thanks for any help.
User avatar
gking
Registered Member
Posts
29
Karma
1
OS

Re: CSV Importer and date format

Sat Oct 29, 2022 11:34 pm
I am seeing something similar with csv import using kmymoney-5.1-179-linux-64-gcc.AppImage .
The date I am trying to import is like "01 JAN 2022", and I have selected "d m y" in the date format dialog, but it refused to accept it and thus I cannot import the file.

I manually edited the file and changed "01 JAN 2022" format to "01-01-2022" format and it worked, so I suspect the plugin has a parsing problem with dates. Interestingly the example banking import in the docs has a date like the one that doesn't work.
jehoshua
Registered Member
Posts
100
Karma
0
OS

Re: CSV Importer and date format

Sun Oct 30, 2022 5:57 am


Currently running Kubuntu 22.04, Plasma 5.24.4, Frameworks 5.92.0, Qt 5.15.3, kernel 5.15.0-46-generic (64-bit), GeForce 840M Graphics
User avatar
ipwizard
KDE Developer
Posts
1359
Karma
6
OS

Re: CSV Importer and date format

Sun Oct 30, 2022 9:53 am
gking wrote:I am seeing something similar with csv import using kmymoney-5.1-179-linux-64-gcc.AppImage .
The date I am trying to import is like "01 JAN 2022", and I have selected "d m y" in the date format dialog, but it refused to accept it and thus I cannot import the file.

I manually edited the file and changed "01 JAN 2022" format to "01-01-2022" format and it worked, so I suspect the plugin has a parsing problem with dates. Interestingly the example banking import in the docs has a date like the one that doesn't work.

I tried to duplicate this here by modifying a file. I was unable to duplicate the problem using kmymoney-5.1-159-linux-64-gcc.AppImage and kmymoney-5.1-274-linux-64-gcc.AppImage. Here's my CSV testfile:

Code: Select all
Bezeichnung Auftragskonto;IBAN Auftragskonto;BIC Auftragskonto;Bankname Auftragskonto;Buchungstag;Valutadatum;Name Zahlungsbeteiligter;IBAN Zahlungsbeteiligter;BIC (SWIFT-Code) Zahlungsbeteiligter;Buchungstext;Verwendungszweck;Betrag;Waehrung;Saldo nach Buchung;Bemerkung;Kategorie;Steuerrelevant;Glaeubiger ID;Mandatsreferenz
Konto;DE71..................;MYBICHIDDEN;Some Bank direkt;01 JAN 2022;01 JAN 2022;;;;Abschluss;Abschluss per 31.12.2021;38,19;EUR;38,19;;;;;

Note: The above is contained in two lines.

Settings of my Banking profile:
Code: Select all
Encoding: ISO-8859-1
Field Delimiter: semicolon
Text Delimiter: quote
Header does contain account number: not marked
Start line: 2
End line: 2
Number: empty
Date: 6
Payee/Description: 7
Category: empty
Memo: 11
Balance: empty
Amount: 12
Debit/Credit indicator: empty
Opposite signs: not marked
Decimal symbol: comma
Thousands symbol: dot
Date format: d m y

Can you import this sample data?


ipwizard, proud to be a member of the KMyMoney forum since its beginning. :-D
openSuSE Leap 15.4 64bit, KF5
User avatar
gking
Registered Member
Posts
29
Karma
1
OS

Re: CSV Importer and date format

Mon Oct 31, 2022 12:52 am
I downloaded the test data and got the same error. I created a new KMM file and a bank account, then tried to import the csv into it. It stops at the same place complaining about the date. I grabbed a few screenshots located at the following link:
https://drive.google.com/file/d/1tOArP9 ... share_link

When I setup a the new KMM file and bank account I used my home country (Canada) if that matters.
User avatar
ipwizard
KDE Developer
Posts
1359
Karma
6
OS

Re: CSV Importer and date format

Mon Oct 31, 2022 3:18 pm
Can you try to import the test data file using the latest KMyMoney version? I added some debug output for the failure which is printed to the terminal window as soon as you press Next on the page with the column selections. I would appreciate if you can provide them to us. Thanks in advance.

If everything works as expected, it prints
Code: Select all
convertDate2 "01 JAN 2022" "01012022" "ddMMyyyy" QDate("2022-01-01")

In your case, it could be more and different output and this one may be missing at all.


ipwizard, proud to be a member of the KMyMoney forum since its beginning. :-D
openSuSE Leap 15.4 64bit, KF5
User avatar
gking
Registered Member
Posts
29
Karma
1
OS

Re: CSV Importer and date format

Tue Nov 01, 2022 11:12 pm
I downloaded kmymoney-master-292-linux-64-gcc.AppImage and did some testing. STDOUT from the tests is file kmm-debug.txt included in the following ZIP file of results located at https://drive.google.com/file/d/1Q-7y_Y ... share_link

It looks like the csv importer is getting confused by the month conversion in the local character set based on the following messages in STDOUT:

Code: Select all
convertDate: Unable to find month "JAN" in
"en_CA" "en-CA" QLocale::English QLocale::Canada QLocale::LatinScript
1 "Jan." "Jan." "January" "January"
2 "Feb." "Feb." "February" "February"
3 "Mar." "Mar." "March" "March"
4 "Apr." "Apr." "April" "April"
5 "May" "May" "May" "May"
6 "Jun." "Jun." "June" "June"


I edited field 6 of the .csv file and tried "Jan" "Jan." without success. However when I changed date to "01 MAY 2022" or "01 May 2022" the importer worked. I suspect "January" would also work. It looks like the "." character in the translation table is causing the importer to fail.
User avatar
ipwizard
KDE Developer
Posts
1359
Karma
6
OS

Re: CSV Importer and date format

Wed Nov 02, 2022 5:25 pm
I see the problem: The columns in the list of month names contain the output of

1. QLocale::standaloneMonthName(ShortFormat),
2. QLocale::monthName(ShortFormat),
3. QLocale::standaloneMonthName(LongFormat),
4. QLocale::monthName(LongFormat).

If I run this on my system I get

Code: Select all
convertDate: Unable to find month "JAN" in
"en_US" "en" QLocale::English QLocale::UnitedStates QLocale::LatinScript
1 "Jan" "Jan." "Januar" "Januar"
2 "Feb" "Feb." "Februar" "Februar"
3 "Mär" "März" "März" "März"
4 "Apr" "Apr." "April" "April"
5 "Mai" "Mai" "Mai" "Mai"
6 "Jun" "Juni" "Juni" "Juni"
7 "Jul" "Juli" "Juli" "Juli"
8 "Aug" "Aug." "August" "August"

Don't worry about the error message that it did not find JAN. That is because I forced it to fail to get this list. The problem is, that the standaloneMonthName method in my locale does not append a dot when used with option ShortName. Passing "Jan." (with the dot) in one of your tests fails, because the dot is removed before the comparison happens (the dot is a separator).

I made some more changes. You can try the latest build which should solve the problem.


ipwizard, proud to be a member of the KMyMoney forum since its beginning. :-D
openSuSE Leap 15.4 64bit, KF5
User avatar
gking
Registered Member
Posts
29
Karma
1
OS

Re: CSV Importer and date format

Sat Nov 05, 2022 7:27 pm
I downloaded kmymoney-master-296-linux-64-gcc.AppImage and reran the test. It now works. STDOUT loog shows:
Code: Select all
Processed home view section 10 in 0 ms
convertDate2 "01 JAN 2022" "01012022" "ddMMyyyy" QDate("2022-01-01")
convertDate2 "01 JAN 2022" "01012022" "ddMMyyyy" QDate("2022-01-01")
KMyMoneyPlugin::KMMStatementInterface::import start
Importing statement for 'Cash'
Processing transactions (Cash)
Process on: '2022-01-01', id: '2022-01-01-230086345-0', symbol: '', amount: '38.19', fees: '0.00'
Looking for a match with transaction:  "2022-01-01" , "" , "38.19" (referenced account:  "Cash" )
Considering 0 existing transaction(s) for matching
Looking for a match with transaction:  "2022-01-01" , "" , "38.19" (referenced account:  "Cash" )
Considering 0 schedule(s) for matching the transaction
Processing transactions done (Cash)


Thanks for fixing this.

Greg
User avatar
ipwizard
KDE Developer
Posts
1359
Karma
6
OS

Re: CSV Importer and date format

Sun Nov 06, 2022 8:49 am
Thanks for the feedback. I also added the fix to the stable branch of the application.


ipwizard, proud to be a member of the KMyMoney forum since its beginning. :-D
openSuSE Leap 15.4 64bit, KF5


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]