quentinsf / icsv2ledger

Interactive importing of CSV files to Ledger
196 stars 70 forks source link

Concatenate desc from multiple csv fields #33

Closed afh closed 12 years ago

afh commented 12 years ago

Some banks issue an account statement that has a payee and a purpose field (see example translated from German below), which make a more precise desc for transaction mapping.

These changes allow the desc configuration in the ~/.icsv2legerrc to be a comma separated list of csv column indices which will be concatenated to form a more precise and unique desc used for mapping.

Example bank statement CSV header with two fields relevant for desc. "Date","Effective Date","Transactiontext","Payee","Purpose","Account","BIN","Amount",

thdox commented 12 years ago

Hi, I understand the usefulness of the proposed change. BUT I do not agree on the way it is implemented. Here is my alternative proposition : addon (I still prefer "field") is implemented to save csv field as names. Then why not using the template like:

{date} {cleared_character} {payee}, {addon_whatever1}, {addon_whatever2}, ; MD5Sum: {md5sum} ; CSV: {csv} {debit_account:<60} {debit_currency} {debit} {credit_account:<60} {credit_currency} {credit}

I also do not agree because ",\s" is hardcoded, and also because comma is certainly a delimiter for the 1 billion English native speakers, but it is decimal separator for 5 billion people.

petdr commented 12 years ago

I think you misunderstand the change, it's simply to make the description coming from the csv file be a concatenation of a number of fields from the csv rather than one field.

afh commented 12 years ago

Thanks for merging.

thdox commented 12 years ago

I may have misunderstood, but I still have not understood. Why the solution I proposed (that is concatenating the fields) is not giving the same results ? And this without code modification.

afh commented 12 years ago

@thdox: The changes affect how icsv2ledger does its mapping by helping to distinguish transactions that may look similar if only one CSV field is used for mapping.

Given the following sample CSV

"Date","Effective Date","Transactiontext","Payee","Purpose","Account","BIN","Amount",
25.10.2012,25.10.2012,online banking,Acme Inc.,Down Payment,1234567890,12312312,100.00

Without the above changes icsv2leger uses only one field for the mapping. In this case we could configure icsv2ledger to use the Payee desc=4 or the Purpose desc=5 field, so only Acme Inc. or Down Payment would be used in the mapping file.

With the above changes I can configure icsv2ledger concatenate any number of fields for mapping use, e.g. Payee and Purpose desc=4,5 which would result in the following string ending up in the mapping file Amce Inc. Down Payment.

Hope this illustrates my intent and use, the changes have already proven very useful for me.

thdox commented 12 years ago

Perfect explanation with the example. Thanks. I know understand how helpful it is. What I had not understood was the relation with the mapping. I was believing it was only for ledger template.

afh commented 12 years ago

Glad that the explanation cleared things up.