Well I was able to use LibreOffice to easily pre-format the CSV file to 
make things a little easier for me with the import code, but no luck yet.

Updated file format looks like this:

Date             Description         Amount              Balance 
12/1/23       PAYMENT          $951.28              $25,000.62

Updated import code looks like this:

```
from beancount_reds_importers.libreader import csvreader
from beancount_reds_importers.libtransactionbuilder import banking

class Importer(csvreader.Importer, banking.Importer):
    IMPORTER_NAME = 'chasemortgage'

    def custom_init(self):
        self.max_rounding_error = 0.04
        self.filename_pattern_def = '*chase.com.csv'
        self.header_identifier = 'Date,Description,Amount,Balance'
        self.date_format = '%x'
        self.header_map = {
            "Description": 'payee',
            "Date":             'date',
            "Amount":       'amount',
            "Balance:":      'balance',
            }
```

I'm getting this error in the terminal:

ERROR:root:Importer importers.chasemortgage.Importer.identify() raised an 
unexpected error: nothing to repeat at position 0

I have tried with and without the balance function tacked onto the end but 
am getting the same error so I think its unrelated to that.

Any ideas on what to try next? Thanks!

On Friday, December 8, 2023 at 9:13:34 PM UTC-5 fin wrote:

> Chris Bond wrote:
> > ------=_Part_10662_427767134.1701975257612
> > Content-Type: multipart/alternative; 
> > boundary="----=_Part_10663_1945899272.1701975257612"
> >
> > ------=_Part_10663_1945899272.1701975257612
> > Content-Type: text/plain; charset="UTF-8"
> >
> > I have what I think may be a very simple CSV file:
> >
> > Column headers are these:
> > Date,Description,Amount,Unapplied,Balance 
> >
> > Corresponding data fields look like this:
> > Dec 1, 2023,PAYMENT,$951.28,$951.28,$25,000.62
>
> you have a comma in the first field, you don't want to use
> dates with commas in them if you are using csv format.
>
> sorry i don't have the time to look into this further but
> i noticed this and thought it worth a comment. :)
>
> good luck,
>
> keep on trying, i learned a lot by doing a lot of 
> experiments and writing my own importers.
>
>
> > I have had some success using Red's ofx importer framework, but am 
> really 
> > struggling to figure out the CSV importer from the examples in the git 
> > repo. I started with the Discover example that looks like this:
> >
> > from beancount_reds_importers.libreader import csvreader
> > from beancount_reds_importers.libtransactionbuilder import banking
> >
> > class Importer(csvreader.Importer, banking.Importer):
> > IMPORTER_NAME = """ Discover credit card .csv importer."""
> >
> > def custom_init(self):
> > self.max_rounding_error = 0.04
> > self.filename_pattern_def = 'Discover.*'
> > self.header_identifier = 'Trans. Date,Post 
> > Date,Description,Amount,Category'
> > self.date_format = '%m/%d/%Y'
> > self.header_map = {
> > "Category": 'payee',
> > "Description": 'memo',
> > "Trans. Date": 'date',
> > "Post Date": 'postDate',
> > "Amount": 'amount',
> > }
> >
> > def skip_transaction(self, ot):
> > return False
> >
> > def prepare_processed_table(self, rdr):
> > # Need to invert numbers supplied by Discover
> > rdr = rdr.convert('amount', lambda x: -1 * x)
> > return rdr
> >
> > I'm pretty sure I don't need the def skip_transaction(self, ot) and def 
> > prepare_processed_table(self, rdr): bits, but am at a loss to figure out 
> > what fields I need to modify in the def custom_init(self) for my 
> situation. 
> > There is not an example CSV file for that importer in the repo so it 
> makes 
> > it a little more challenging for me to hack on it. I think I don't need 
> the 
> > "Unapplied" column but am not sure. Even just some hints would be really 
> > helpful. 
> >
> > Thank you in advance!
> > Chris
> >
>
> fin
>
>

-- 
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 beancount+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/e11cdcaf-4c1b-4154-a731-76cd805b3482n%40googlegroups.com.

Reply via email to