icsv2ledger icon indicating copy to clipboard operation
icsv2ledger copied to clipboard

--skip-dupes does not, somewhat unexpectedly, skip the prompts to enter payee and account

Open cammil opened this issue 6 years ago • 3 comments

It seems the prompt for entering payee and account still appears, even though that line of the csv has already been "dealt with".

What I got:

~ echo "2018/01/01,someshop,-5\n" > in.csv
~ icsv2ledger.py --skip-lines=0 --csv-date-format=%Y/%m/%d --credit 3 --debit 0 --desc 2 --skip-dupes --account Assets:Checking in.csv out.csv

2018/01/01 someshop                                 -5
Payee [someshop] >
Account [Expenses:Unknown] >
~ cat out.csv
2018/01/01 * someshop
    ; MD5Sum: 57d3077de9bff6d607111ed9e3a882d0
    ; CSV: 2018/01/01,someshop,-5
    Expenses:Unknown
    Assets:Bank:Current                                             £ -5

~ icsv2ledger.py --skip-lines=0 --csv-date-format=%Y/%m/%d --credit 3 --debit 0 --desc 2 --skip-dupes --account Assets:Checking in.csv out.csv

2018/01/01 someshop                                 -5
Payee [someshop] >
Account [Expenses:Unknown] >
~ cat out.csv
2018/01/01 * someshop
    ; MD5Sum: 57d3077de9bff6d607111ed9e3a882d0
    ; CSV: 2018/01/01,someshop,-5
    Expenses:Unknown
    Assets:Bank:Current                                             £ -5

What I expected:

~ echo "2018/01/01,someshop,-5\n" > in.csv
~ icsv2ledger.py --skip-lines=0 --csv-date-format=%Y/%m/%d --credit 3 --debit 0 --desc 2 --skip-dupes --account Assets:Checking in.csv out.csv

2018/01/01 someshop                                 -5
Payee [someshop] >
Account [Expenses:Unknown] >
~ cat out.csv
2018/01/01 * someshop
    ; MD5Sum: 57d3077de9bff6d607111ed9e3a882d0
    ; CSV: 2018/01/01,someshop,-5
    Expenses:Unknown
    Assets:Bank:Current                                             £ -5

~ icsv2ledger.py --skip-lines=0 --csv-date-format=%Y/%m/%d --credit 3 --debit 0 --desc 2 --skip-dupes --account Assets:Checking in.csv out.csv
<<<Nothing here, or perhaps some helpful message>>>
~ cat out.csv
2018/01/01 * someshop
    ; MD5Sum: 57d3077de9bff6d607111ed9e3a882d0
    ; CSV: 2018/01/01,someshop,-5
    Expenses:Unknown
    Assets:Bank:Current                                             £ -5

cammil avatar May 19 '18 10:05 cammil

@cammil Same here, any progress on that issue?

RidaAyed avatar Jun 24 '18 16:06 RidaAyed

For me it did not skip adding the records either. Every time I ran an import with --skip-dupes and the same input/output files I get new identical records appended to the output file, including the MD5 sums.

I noticed the code only checks the --skip-dupes if --skip-older-than isn't set, and I don't use that so no problem there. After some debugging I then noticed it never even parsed MD5 sums from my ledger file.

Turns out you have to also use the --ledger-file option to specify where it should read existing transactions from.

Something else I also realized is that NOT using --incremental for some reason truncates the outfile as soon as the program starts! By the description it just sounds like leaving out --incremental just does not write anything to the output file until the input file is completely parsed, not that it will destroy any existing data as soon as you launch it without that option!

TwoD avatar Jan 12 '19 20:01 TwoD

Turns out you have to also use the --ledger-file option to specify where it should read existing transactions from.

Worked for me!

jcrben avatar Mar 14 '19 06:03 jcrben