Hi Martin,

Just started using beancount to get away from Quicken.  Your reasons for 
writing it and the documentation was my reason to give it a try.  It should 
also help my Python skills.  You sort of  have an example in csv_test.py. 
 It helped me determine what to put in my .import file.  Strangely, csv.py 
and csv_test.py were not in my install, ofx.py and others were.  I just 
copied 
from 
https://bitbucket.org/blais/beancount/src/b73da2b4f8e3182b1fb537a75385406c6d4fee90/src/python/beancount/ingest/importers/csv.py?at=booking&fileviewer=file-view-default
 
and moved to the directory where ofx.py was and it worked, sort of.

I ran bean-identify, then the bean-extract as in the example, but I used a 
file, not a directory.  However, the only thing in the output file was the 
header and the path/filename.  No transactions made it into the file. 
 Maybe the regexp input?  I sort of guessed on that, I couldn't exactly see 
what to put in there except the headings.  Here is the import file I 
created.

#!/usr/bin/env python3
"""Example import configuration."""

# Insert our custom importers path here.
# (In practice you might just change your PYTHONPATH environment.)
import sys
from os import path
sys.path.insert(0, path.join(path.dirname(__file__)))

from beancount.ingest import extract
from beancount.ingest.importers import ofx
from beancount.ingest.importers import csv

Col = csv.Col

# Setting this variable provides a list of importer instances.
CONFIG = [
    csv.Importer({Col.DATE: 'Posted Date',
                  Col.TXN_DATE: 'Transaction Date',
                  Col.NARRATION1: 'Card No.',
                  Col.NARRATION2: 'Description',
                  Col.NARRATION3: 'Catagory',
                  Col.AMOUNT_DEBIT: 'Debit',
                  Col.AMOUNT_CREDIT: 'Credit'},
                 'Liabilities:US:CapOne',
                 'USD',
                 ('Transaction Date,Posted Date,Card No.,Description,'
                     'Category,Debit,Credit'),
                 'CapOne')
]


# Override the header on extracted text (if desired).
extract.HEADER = ';; -*- mode: org; mode: beancount; coding: utf-8; -*-\n'


Am I correct in thinking I would need a separate import file for each 
different type of csv?

Thanks

Jonathan

On Friday, October 21, 2016 at 11:20:55 PM UTC-4, Martin Blais wrote:
>
> On Wed, Oct 19, 2016 at 4:19 AM, Saša Janiška <[email protected] 
> <javascript:>> wrote:
>
>> Hello,
>>
>> afaik, (h)ledger have some general CSV importer where one can define
>> some mapping rules for the desired CSV format and then import?
>>
>> CSV is also the only format I can use since the bank just provides Excel
>> file which can be converted to CSV.
>>
>
> Beancount offers a framework to define your own custom importers, 
> documented here:
> http://furius.ca/beancount/doc/ingest
>
> Unfortunately, you have to write some code to set that up.
>
> On the other hand, it also comes with a good example CSV importer which is 
> functional:
>
> https://bitbucket.org/blais/beancount/src/b73da2b4f8e3182b1fb537a75385406c6d4fee90/src/python/beancount/ingest/importers/csv.py?at=booking&fileviewer=file-view-default
>
> You just need to instantiate it and provide it with a dict that tells it 
> how to interpret each column of your CSV file.
> (I should provide some example on how to do that, in the meantime you'd 
> have to read the source code.)
>
> HTH,
>
>
>
>
> Sincerely,
>> Gour
>>
>> --
>> While contemplating the objects of the senses, a person
>> develops attachment for them, and from such attachment lust
>> develops, and from lust anger arises.
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/beancount/874m48rbsv.fsf%40atmarama.com
>> .
>> 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/89102a4b-26aa-4c5e-82c6-0400d6268c38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to