Hi,
I'm trying to get importing a CSV file to work. bean-identify tells me this:
$ bean-identify personal.import Downloads
**** /home/user/personal/finance/accounting/Downloads/Hudsons.csv
Importer: importers.hudsons.Importer: "Liabilities:CA:HudsonsBay:Mastercard"
Account: Liabilities:CA:HudsonsBay:Mastercard
So I know that this part works. However, when I try to do the extract, I get this:
$ bean-extract personal.import Downloads
ERROR:root:Importer importers.hudsons.Importer: "Liabilities:CA:HudsonsBay:Mastercard".extract() raised an unexpected error: Could not determine delimiter
ERROR:root:Traceback: Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/beancount/ingest/extract.py", line 191, in extract
allow_none_for_tags_and_links=allow_none_for_tags_and_links)
File "/usr/lib/python3/dist-packages/beancount/ingest/extract.py", line 69, in extract_from_file
new_entries = importer.extract(file, **kwargs)
File "/usr/lib/python3/dist-packages/beancount/ingest/importers/csv.py", line 186, in extract
iconfig, has_header = normalize_config(self.config, file.head(), self.csv_dialect)
File "/usr/lib/python3/dist-packages/beancount/ingest/importers/csv.py", line 324, in normalize_config
has_header = csv.Sniffer().has_header(head)
File "/usr/lib/python3.7/csv.py", line 394, in has_header
rdr = reader(StringIO(sample), self.sniff(sample))
File "/usr/lib/python3.7/csv.py", line 188, in sniff
raise Error("Could not determine delimiter")
_csv.Error: Could not determine delimiter
;; -*- mode: org; mode: beancount; coding: utf-8; -*-
The csv file looks pretty normal, it looks like this:
Stage,Transaction Date,Posted Date,Card No.,Description,Debit,Credit
POSTED,2019-02-09,2019-02-11,4524,PHARMAPRIX #0029 MONTREAL QC,14.69
POSTED,2019-02-09,2019-02-11,4524,RACHELLE-BERY #8617 MONTREAL QC,80.95
etc.
My __init__.py looks like this:
#!/usr/bin/env python3
from beancount.ingest import regression
from beancount.ingest.importers import csv
from beancount.plugins import auto_accounts
class Importer(csv.Importer):
config = {csv.Col.DATE: 'Posted Date',
csv.Col.TXN_DATE: 'Transaction Date',
csv.Col.NARRATION: 'Description',
csv.Col.AMOUNT_CREDIT: 'Credit',
csv.Col.AMOUNT_DEBIT: 'Debit'}
def __init__(self, account):
csv.Importer.__init__(
self, self.config,
account, 'CAD',
('Stage,Transaction Date,Posted Date,Card No.,Description,'
'Debit,Credit'),
1)
def get_description(self, row):
payee, narration = super().get_description()
narration = '{} ({})'.format(narration, row.category)
return payee, narration
Is there something I'm missing here?
Thanks!
crust