Issue #419: how to extend precanned csv import extract method to add csv source to __source__ metadata (blais/beancount)

8 views
Skip to first unread message

Jeff Mondoux

unread,
Feb 14, 2020, 12:23:34 PM2/14/20
to bean...@googlegroups.com
New issue 419: how to extend precanned csv import extract method to add csv source to __source__ metadata
https://bitbucket.org/blais/beancount/issues/419/how-to-extend-precanned-csv-import-extract

Jeff Mondoux:

I have a custom importer to import my banks csv statements, this imported inherits from beancount csv importer in which I override the extract\(\) method as such:

```
def extract(self, file, existing_entries=None):
mapped_account = self.file_account(file)
entries = super().extract(file, existing_entries)
for entry in entries:
entry.meta['__source__']='source'
return entries
```

What I can’t figure out with my limited python abilities is how can I add the raw csv line to the \_\_**source**\_\_ metadata field so that it can be displayed by fava import gui. I want to avoid rolling my own csv importer entirely as the generic csv importer provided by beancount does what I need for the most part. I know I can reread the csv file a second time to append the data, but is this the best or only way?


Reply all
Reply to author
Forward
0 new messages