Your CSV file looks normal.
The CSV sniffer - the piece of code which attempts to automatically detect
the dialect / separator from a CSV file contents - fails, for some reason
I'm not familiar with.
Try specifying the delimiter explicitly.

On Thu, Feb 14, 2019 at 10:41 PM <[email protected]> wrote:

> 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
>
> --
> You received this message because you are subscribed to the Google Groups
> "Beancount" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beancount/4073e7ff-1da6-42d1-8808-40e8dcce6951%40googlegroups.com
> <https://groups.google.com/d/msgid/beancount/4073e7ff-1da6-42d1-8808-40e8dcce6951%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAK21%2BhPnVQHxWwxgMS_j%3DB5K4AuU6b-0mCzOQ45HbtMRGRTKZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to