iconfig in CSV Importer categorizer call #103
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In dd50f53 the
row
argument was added to the CSV Importer'scategorizer
function. With this second argument, it became very easy to add extra Postings onto an already created Transaction.However, this way of adding Postings is dependent on knowing the indices of columns in advance. You have to know that the "payee" column is
row[2]
, etc. This is especially problematic if the CSV files being imported don't have columns in a deterministic order (e.g. if they're created by another Python script) or if your bank/financial institution suddenly adds or removes a column.With this PR, the
iconfig
dictionary that maps column type -> index would be included as a third parameter.Caveat: workarounds exist
I know that we can use partial functions or callable class instances to bind the iconfig dictionary to our categorizer callable ahead of time. But it chafes me to have to open the file twice,
normalize_config
twice, etc.