Help a Beginner with Red's CSV Importer?

322 views
Skip to first unread message

Chris Bond

unread,
Dec 7, 2023, 10:06:19 PM12/7/23
to Beancount
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

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

Red S

unread,
Dec 8, 2023, 3:19:53 AM12/8/23
to Beancount

Hello there,
Author here. Given how simple your csv file is, I’d suggest using Beancount’s built in csv importer. Something like this in your my.import file (untested):

csv.Importer({Col.DATE: 'Date', Col.NARRATION1: 'Description', Col.AMOUNT: 'Amount', }, 'Assets:Bank1', 'USD', ('Date','Description','Amount','Unapplied','Balance')),

The only advantage you get with my reds-importers is balance assertions. I'll post and example in a minute.

​

Red S

unread,
Dec 8, 2023, 3:33:44 AM12/8/23
to Beancount

Argh, don’t have my laptop now, so this is hard, but with the init function, the right hand fields in the dictionary are internal, and fixed. The left hand side corresponds to your csv file.

Date,Description,Amount,Unapplied,Balance

def custom_init(self): self.max_rounding_error = 0.04 self.filename_pattern_def = '<change_this>.*' self.header_identifier = 'Date,Description,Amount,Unapplied,Balance', self.date_format = '%m/%d/%Y' # <--- this is incorrect, change this self.header_map = { "Description": 'payee', "Date": 'date', "Amount": 'amount', "Balance": 'balance', }

I can’t remember of the top of my head if you need a get_balance_statement() function to generate the balance assertion. If you do, it’ll look like this.

This is all untested. If that doesn’t work, let me know.

​

Chris Bond

unread,
Dec 8, 2023, 7:15:51 AM12/8/23
to Beancount
Thanks! Will test this out.

fin

unread,
Dec 8, 2023, 9:13:34 PM12/8/23
to bean...@googlegroups.com
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.
fin

Chris Bond

unread,
Dec 10, 2023, 8:12:27 AM12/10/23
to Beancount
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!

fin

unread,
Dec 10, 2023, 1:12:19 PM12/10/23
to bean...@googlegroups.com
Chris Bond wrote:
> ------=_Part_4968_1593684340.1702208487217
> Content-Type: multipart/alternative;
> boundary="----=_Part_4969_1824196410.1702208487217"
>
> ------=_Part_4969_1824196410.1702208487217
> Content-Type: text/plain; charset="UTF-8"
> Content-Transfer-Encoding: quoted-printable
>
> Well I was able to use LibreOffice to easily pre-format the CSV file to=20
> 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=20
> 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 =3D 'chasemortgage'
>
> def custom_init(self):
> self.max_rounding_error =3D 0.04
> self.filename_pattern_def =3D '*chase.com.csv'
> self.header_identifier =3D 'Date,Description,Amount,Balance'
> self.date_format =3D '%x'
> self.header_map =3D {
> "Description": 'payee',
> "Date": 'date',
> "Amount": 'amount',
> "Balance:": 'balance',
> }
> ```

you have description before date, but in your data
the date comes first.

also, with csv the fields should be separated by
commas, but i see no field separators, and again you
have a comma in a field which will throw things off
unless the data is surrounded by quotation marks and
your importer is looking for matched quotation marks
(not all will allow commas anywhere else no matter
what so that's up to you to fix or test).

i stop here with my comments because if you don't
have the format and field names correct than anything
else is going to likely not work well...


fin


> I'm getting this error in the terminal:
>
> ERROR:root:Importer importers.chasemortgage.Importer.identify() raised an=
>=20
> unexpected error: nothing to repeat at position 0
>
> I have tried with and without the balance function tacked onto the end but=
>=20
> 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=E2=80=AFPM UTC-5 fin wrote:
>
>> Chris Bond wrote:
>> > ------=3D_Part_10662_427767134.1701975257612
>> > Content-Type: multipart/alternative;=20
>> > boundary=3D"----=3D_Part_10663_1945899272.1701975257612"
>> >
>> > ------=3D_Part_10663_1945899272.1701975257612
>> > Content-Type: text/plain; charset=3D"UTF-8"
>> >
>> > I have what I think may be a very simple CSV file:
>> >
>> > Column headers are these:
>> > Date,Description,Amount,Unapplied,Balance=20
>> >
>> > 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=20
>> experiments and writing my own importers.
>>
>>
>> > I have had some success using Red's ofx importer framework, but am=20
>> really=20
>> > struggling to figure out the CSV importer from the examples in the git=
>=20
>> > 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 =3D """ Discover credit card .csv importer."""
>> >
>> > def custom_init(self):
>> > self.max_rounding_error =3D 0.04
>> > self.filename_pattern_def =3D 'Discover.*'
>> > self.header_identifier =3D 'Trans. Date,Post=20
>> > Date,Description,Amount,Category'
>> > self.date_format =3D '%m/%d/%Y'
>> > self.header_map =3D {
>> > "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 =3D 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=
>=20
>> > prepare_processed_table(self, rdr): bits, but am at a loss to figure ou=
> t=20
>> > what fields I need to modify in the def custom_init(self) for my=20
>> situation.=20
>> > There is not an example CSV file for that importer in the repo so it=20
>> makes=20
>> > it a little more challenging for me to hack on it. I think I don't need=
>=20
>> the=20
>> > "Unapplied" column but am not sure. Even just some hints would be reall=
> y=20
>> > helpful.=20
>> >
>> > Thank you in advance!
>> > Chris
>> >
>>
>> fin
>>
>>
>
> --=20
> 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 e=
> mail to beancount+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/=
> beancount/e11cdcaf-4c1b-4154-a731-76cd805b3482n%40googlegroups.com.
>
> ------=_Part_4969_1824196410.1702208487217
> Content-Type: text/html; charset="UTF-8"
> Content-Transfer-Encoding: quoted-printable
>
><div>Well I was able to use LibreOffice to easily pre-format the CSV file t=
> o make things a little easier for me with the import code, but no luck yet.=
><br /></div><div><br /></div><div>Updated file format looks like this:<br /=
>></div><div><br /></div><div><div><span cellspacing=3D"0" border=3D"0"><spa=
> n><span><span height=3D"17" align=3D"left"></span></span></span></span></di=
> v><div><span cellspacing=3D"0" border=3D"0"><span><span><span height=3D"17"=
> align=3D"left">Date</span>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
>=C2=A0=C2=A0=C2=A0=C2=A0 <span align=3D"left">Description</span>=C2=A0=C2=
>=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <span align=3D"left">Amount</span>=
>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
>=A0 <span align=3D"left">Balance</span>
> </span>
> <span>
> <span height=3D"17" align=3D"left"></span></span></span></span></div><div=
>><span cellspacing=3D"0" border=3D"0"><span><span><span height=3D"17" align=
>=3D"left"></span></span></span></span></div><div><span cellspacing=3D"0" bo=
> rder=3D"0"><span><span><span height=3D"17" align=3D"left"></span></span></s=
> pan></span></div><div><span cellspacing=3D"0" border=3D"0"><span><span><spa=
> n height=3D"17" align=3D"left">12/1/23=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =
></span></span></span></span><span cellspacing=3D"0" border=3D"0"><span><spa=
> n><span align=3D"left">PAYMENT=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 =
></span></span></span></span><span cellspacing=3D"0" border=3D"0"><span><spa=
> n><span align=3D"left">$951.28</span></span></span></span>=C2=A0=C2=A0=C2=
>=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <span cells=
> pacing=3D"0" border=3D"0"><span><span><span align=3D"left">$25,000.62</span=
>></span></span></span></div><div><br /><span cellspacing=3D"0" border=3D"0"=
>><span><span><span align=3D"left"></span></span></span></span></div><div><s=
> pan cellspacing=3D"0" border=3D"0"><span><span><span align=3D"left">Updated=
> import code looks like this:</span></span></span></span></div><div><span c=
> ellspacing=3D"0" border=3D"0"><span><span><span align=3D"left"><br /></span=
>></span></span></span></div><div><span><span>```</span></span></div><div>fr=
> om beancount_reds_importers.libreader import csvreader<br />from beancount_=
> reds_importers.libtransactionbuilder import banking<br /><br />class Import=
> er(csvreader.Importer, banking.Importer):<br />=C2=A0 =C2=A0 IMPORTER_NAME =
>=3D 'chasemortgage'</div><div><br /></div><div>=C2=A0 =C2=A0 def custom_ini=
> t(self):<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.max_rounding_error =3D 0.04<=
> br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.filename_pattern_def =3D '*chase.com.=
> csv'<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.header_identifier =3D 'Date,Desc=
> ription,Amount,Balance'<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.date_format =
>=3D '%x'<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.header_map =3D {<br />=C2=A0=
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Description": 'payee',<br />=C2=A0 =C2=
>=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Date": =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=
>=C2=A0=C2=A0=C2=A0 'date',<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "=
> Amount": =C2=A0 =C2=A0 =C2=A0 'amount',<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
>=C2=A0 =C2=A0 "Balance:": =C2=A0 =C2=A0=C2=A0 'balance',<br />=C2=A0 =C2=A0=
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 }</div><div><span><span>```</span></span></div=
>><div><br /></div><div>I'm getting this error in the terminal:</div><div><b=
> r /></div><div>ERROR:root:Importer importers.chasemortgage.Importer.identif=
> y() raised an unexpected error: nothing to repeat at position 0</div><div><=
> br /></div><div>I have tried with and without the balance function tacked o=
> nto the end but am getting the same error so I think its unrelated to that.=
><br /></div><div><br /></div><div>Any ideas on what to try next? Thanks!</d=
> iv><div><br /></div></div><div class=3D"gmail_quote"><div dir=3D"auto" clas=
> s=3D"gmail_attr">On Friday, December 8, 2023 at 9:13:34=E2=80=AFPM UTC-5 fi=
> n wrote:<br/></div><blockquote class=3D"gmail_quote" style=3D"margin: 0 0 0=
> 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Chri=
> s Bond wrote:
><br>&gt; ------=3D_Part_10662_427767134.1701975257612
><br>&gt; Content-Type: multipart/alternative;=20
><br>&gt; boundary=3D&quot;----=3D_Part_10663_1945899272.1701975257612&quot=
> ;
><br>&gt;
><br>&gt; ------=3D_Part_10663_1945899272.1701975257612
><br>&gt; Content-Type: text/plain; charset=3D&quot;UTF-8&quot;
><br>&gt;
><br>&gt; I have what I think may be a very simple CSV file:
><br>&gt;
><br>&gt; Column headers are these:
><br>&gt; Date,Description,Amount,Unapplied,Balance=20
><br>&gt;
><br>&gt; Corresponding data fields look like this:
><br>&gt; Dec 1, 2023,PAYMENT,$951.28,$951.28,$25,000.62
><br>
><br> you have a comma in the first field, you don&#39;t want to use
><br>dates with commas in them if you are using csv format.
><br>
><br> sorry i don&#39;t have the time to look into this further but
><br>i noticed this and thought it worth a comment. :)
><br>
><br> good luck,
><br>
><br> keep on trying, i learned a lot by doing a lot of=20
><br>experiments and writing my own importers.
><br>
><br>
><br>&gt; I have had some success using Red&#39;s ofx importer framework, bu=
> t am really=20
><br>&gt; struggling to figure out the CSV importer from the examples in the=
> git=20
><br>&gt; repo. I started with the Discover example that looks like this:
><br>&gt;
><br>&gt; from beancount_reds_importers.libreader import csvreader
><br>&gt; from beancount_reds_importers.libtransactionbuilder import banking
><br>&gt;
><br>&gt; class Importer(csvreader.Importer, banking.Importer):
><br>&gt; IMPORTER_NAME =3D &quot;&quot;&quot; Discover credit card .csv=
> importer.&quot;&quot;&quot;
><br>&gt;
><br>&gt; def custom_init(self):
><br>&gt; self.max_rounding_error =3D 0.04
><br>&gt; self.filename_pattern_def =3D &#39;Discover.*&#39;
><br>&gt; self.header_identifier =3D &#39;Trans. Date,Post=20
><br>&gt; Date,Description,Amount,Category&#39;
><br>&gt; self.date_format =3D &#39;%m/%d/%Y&#39;
><br>&gt; self.header_map =3D {
><br>&gt; &quot;Category&quot;: &#39;payee&#39;,
><br>&gt; &quot;Description&quot;: &#39;memo&#39;,
><br>&gt; &quot;Trans. Date&quot;: &#39;date&#39;,
><br>&gt; &quot;Post Date&quot;: &#39;postDate&#39;,
><br>&gt; &quot;Amount&quot;: &#39;amount&#39;,
><br>&gt; }
><br>&gt;
><br>&gt; def skip_transaction(self, ot):
><br>&gt; return False
><br>&gt;
><br>&gt; def prepare_processed_table(self, rdr):
><br>&gt; # Need to invert numbers supplied by Discover
><br>&gt; rdr =3D rdr.convert(&#39;amount&#39;, lambda x: -1 * x)
><br>&gt; return rdr
><br>&gt;
><br>&gt; I&#39;m pretty sure I don&#39;t need the def skip_transaction(self=
> , ot) and def=20
><br>&gt; prepare_processed_table(self, rdr): bits, but am at a loss to figu=
> re out=20
><br>&gt; what fields I need to modify in the def custom_init(self) for my s=
> ituation.=20
><br>&gt; There is not an example CSV file for that importer in the repo so =
> it makes=20
><br>&gt; it a little more challenging for me to hack on it. I think I don&#=
> 39;t need the=20
><br>&gt; &quot;Unapplied&quot; column but am not sure. Even just some hints=
> would be really=20
><br>&gt; helpful.=20
><br>&gt;
><br>&gt; Thank you in advance!
><br>&gt; Chris
><br>&gt;
><br>
><br> fin
><br>
><br></blockquote></div>
>
><p></p>
>
> -- <br />
> You received this message because you are subscribed to the Google Groups &=
> quot;Beancount&quot; group.<br />
> To unsubscribe from this group and stop receiving emails from it, send an e=
> mail to <a href=3D"mailto:beancount+...@googlegroups.com">beancount=
> +unsub...@googlegroups.com</a>.<br />
> To view this discussion on the web visit <a href=3D"https://groups.google.c=
> om/d/msgid/beancount/e11cdcaf-4c1b-4154-a731-76cd805b3482n%40googlegroups.c=
> om?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgi=
> d/beancount/e11cdcaf-4c1b-4154-a731-76cd805b3482n%40googlegroups.com</a>.<b=
> r />
>
> ------=_Part_4969_1824196410.1702208487217--
>
> ------=_Part_4968_1593684340.1702208487217--
>

Red S

unread,
Dec 11, 2023, 5:04:08 AM12/11/23
to Beancount
you have description before date, but in your data
the date comes first.

It's a python dictionary, so the order doesn't matter.
 
also, with csv the fields should be separated by
commas, but i see no field separators, and again you
have a comma in a field which will throw things off

Indeed, this is the problem. 

Red S

unread,
Dec 11, 2023, 5:04:31 AM12/11/23
to Beancount
As the post above said, that pre-formatting changed it. It's not a csv file any more, and can't be imported :).

Basically, comfort with python debugging, csv files and such and such is unfortunately a pre-requisite for writing your own importer, even with reds-importers. Without that, it's hard to get someone over the initial hump via messaging here. If that is not an option right now, I'd suggest starting with the simple option of importing with Beancount's built in csv import for your file here, and adding the balance manually on each import for now, until you get comfortable with your workflow and figure out the biggest problems to solve.

Chris Bond

unread,
Dec 11, 2023, 8:29:52 AM12/11/23
to Beancount
Sorry for my typo in previous post. Here is everything I have right now in the CSV file:

Date,Description,Amount,Balance
12/1/23,PAYMENT,951.28,25000.62

Here is my importer code:

```
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 = {
            "Date":             'date',
            "Description": 'payee',

            "Amount":       'amount',
            "Balance:":      'balance',
            }
```

I just keep getting "ERROR:root:Importer importers.chasemortgage.Importer.identify() raised an unexpected error: nothing to repeat at position 0" and really have no idea what that means. Any additional thoughts would be very welcome!

fin

unread,
Dec 13, 2023, 9:06:16 PM12/13/23
to bean...@googlegroups.com
Chris Bond wrote:
> ------=_Part_4422_1215321251.1702256755797
> Content-Type: multipart/alternative;
> boundary="----=_Part_4423_2068436066.1702256755797"
>
> ------=_Part_4423_2068436066.1702256755797
> Content-Type: text/plain; charset="UTF-8"
> Content-Transfer-Encoding: quoted-printable
>
> Sorry for my typo in previous post. Here is everything I have right now in=
>=20
> the CSV file:
>
> Date,Description,Amount,Balance=20
> 12/1/23,PAYMENT,951.28,25000.62
>
> Here is my importer code:
>
> ```
> from beancount_reds_importers.libreader import csvreader
> from beancount_reds_importers.libtransactionbuilder import banking
>
> class Importer(csvreader.Importer, banking.Importer):
> IMPORTER_NAME =3D 'chasemortgage'
>
> def custom_init(self):
> self.max_rounding_error =3D 0.04
> self.filename_pattern_def =3D '*chase.com.csv'
> self.header_identifier =3D 'Date,Description,Amount,Balance'
> self.date_format =3D '%x'
>
> self.header_map =3D {
> "Date": 'date',
> "Description": 'payee',
> "Amount": 'amount',
> "Balance:": 'balance',
> }
> ```
>
> I just keep getting "ERROR:root:Importer=20
> importers.chasemortgage.Importer.identify() raised an unexpected error:=20
> nothing to repeat at position 0" and really have no idea what that means.=
>=20
> Any additional thoughts would be very welcome!

how are you running this? what is your environment like?
do you have the right paths set up? what is your directory
like where you are running this? etc.

pretty much what it looks like to me is that it is trying
to run but it may not be finding the data file for some
reason. this is just a guess. :)

if you are following a tutorial or directions from someone
maybe they have it wrong as things do change and sometimes
you just have to figure it out.

put print statements in places and see what the output
looks like or trace it with a debugger and see where it
blows chunks. backtraces, etc.


fin


> On Sunday, December 10, 2023 at 1:12:19=E2=80=AFPM UTC-5 fin wrote:
>
> Chris Bond wrote:=20
>> ------=3D_Part_4968_1593684340.1702208487217=20
>> Content-Type: multipart/alternative;=20
>> boundary=3D"----=3D_Part_4969_1824196410.1702208487217"=20
>>=20
>> ------=3D_Part_4969_1824196410.1702208487217=20
>> Content-Type: text/plain; charset=3D"UTF-8"=20
>> Content-Transfer-Encoding: quoted-printable=20
>>=20
>> Well I was able to use LibreOffice to easily pre-format the CSV file=20
> to=3D20=20
>> make things a little easier for me with the import code, but no luck yet.=
>=20
>>=20
>> Updated file format looks like this:=20
>>=20
>> Date Description Amount Balance=3D20=20
>> 12/1/23 PAYMENT $951.28 $25,000.62=20
>>=20
>> Updated import code looks like this:=20
>>=20
>> ```=20
>> from beancount_reds_importers.libreader import csvreader=20
>> from beancount_reds_importers.libtransactionbuilder import banking=20
>>=20
>> class Importer(csvreader.Importer, banking.Importer):=20
>> IMPORTER_NAME =3D3D 'chasemortgage'=20
>>=20
>> def custom_init(self):=20
>> self.max_rounding_error =3D3D 0.04=20
>> self.filename_pattern_def =3D3D '*chase.com.csv'=20
>> self.header_identifier =3D3D 'Date,Description,Amount,Balance'=20
>> self.date_format =3D3D '%x'=20
>> self.header_map =3D3D {=20
>> "Description": 'payee',=20
>> "Date": 'date',=20
>> "Amount": 'amount',=20
>> "Balance:": 'balance',=20
>> }=20
>> ```=20
>
> you have description before date, but in your data=20
> the date comes first.=20
>
> also, with csv the fields should be separated by=20
> commas, but i see no field separators, and again you=20
> have a comma in a field which will throw things off=20
> unless the data is surrounded by quotation marks and=20
> your importer is looking for matched quotation marks=20
> (not all will allow commas anywhere else no matter=20
> what so that's up to you to fix or test).=20
>
> i stop here with my comments because if you don't=20
> have the format and field names correct than anything=20
> else is going to likely not work well...=20
>
>
> fin=20
>
>
>> I'm getting this error in the terminal:=20
>>=20
>> ERROR:root:Importer importers.chasemortgage.Importer.identify() raised=20
> an=3D=20
>>=3D20=20
>> unexpected error: nothing to repeat at position 0=20
>>=20
>> I have tried with and without the balance function tacked onto the end=20
> but=3D=20
>>=3D20=20
>> am getting the same error so I think its unrelated to that.=20
>>=20
>> Any ideas on what to try next? Thanks!=20
>>=20
>> On Friday, December 8, 2023 at 9:13:34=3DE2=3D80=3DAFPM UTC-5 fin wrote:=
>=20
>>=20
>>> Chris Bond wrote:=20
>>> > ------=3D3D_Part_10662_427767134.1701975257612=20
>>> > Content-Type: multipart/alternative;=3D20=20
>>> > boundary=3D3D"----=3D3D_Part_10663_1945899272.1701975257612"=20
>>> >=20
>>> > ------=3D3D_Part_10663_1945899272.1701975257612=20
>>> > Content-Type: text/plain; charset=3D3D"UTF-8"=20
>>> >=20
>>> > I have what I think may be a very simple CSV file:=20
>>> >=20
>>> > Column headers are these:=20
>>> > Date,Description,Amount,Unapplied,Balance=3D20=20
>>> >=20
>>> > Corresponding data fields look like this:=20
>>> > Dec 1, 2023,PAYMENT,$951.28,$951.28,$25,000.62=20
>>>=20
>>> you have a comma in the first field, you don't want to use=20
>>> dates with commas in them if you are using csv format.=20
>>>=20
>>> sorry i don't have the time to look into this further but=20
>>> i noticed this and thought it worth a comment. :)=20
>>>=20
>>> good luck,=20
>>>=20
>>> keep on trying, i learned a lot by doing a lot of=3D20=20
>>> experiments and writing my own importers.=20
>>>=20
>>>=20
>>> > I have had some success using Red's ofx importer framework, but am=3D2=
> 0=20
>>> really=3D20=20
>>> > struggling to figure out the CSV importer from the examples in the=20
> git=3D=20
>>=3D20=20
>>> > repo. I started with the Discover example that looks like this:=20
>>> >=20
>>> > from beancount_reds_importers.libreader import csvreader=20
>>> > from beancount_reds_importers.libtransactionbuilder import banking=20
>>> >=20
>>> > class Importer(csvreader.Importer, banking.Importer):=20
>>> > IMPORTER_NAME =3D3D """ Discover credit card .csv importer."""=20
>>> >=20
>>> > def custom_init(self):=20
>>> > self.max_rounding_error =3D3D 0.04=20
>>> > self.filename_pattern_def =3D3D 'Discover.*'=20
>>> > self.header_identifier =3D3D 'Trans. Date,Post=3D20=20
>>> > Date,Description,Amount,Category'=20
>>> > self.date_format =3D3D '%m/%d/%Y'=20
>>> > self.header_map =3D3D {=20
>>> > "Category": 'payee',=20
>>> > "Description": 'memo',=20
>>> > "Trans. Date": 'date',=20
>>> > "Post Date": 'postDate',=20
>>> > "Amount": 'amount',=20
>>> > }=20
>>> >=20
>>> > def skip_transaction(self, ot):=20
>>> > return False=20
>>> >=20
>>> > def prepare_processed_table(self, rdr):=20
>>> > # Need to invert numbers supplied by Discover=20
>>> > rdr =3D3D rdr.convert('amount', lambda x: -1 * x)=20
>>> > return rdr=20
>>> >=20
>>> > I'm pretty sure I don't need the def skip_transaction(self, ot) and=20
> def=3D=20
>>=3D20=20
>>> > prepare_processed_table(self, rdr): bits, but am at a loss to figure=
>=20
> ou=3D=20
>> t=3D20=20
>>> > what fields I need to modify in the def custom_init(self) for my=3D20=
>=20
>>> situation.=3D20=20
>>> > There is not an example CSV file for that importer in the repo so=20
> it=3D20=20
>>> makes=3D20=20
>>> > it a little more challenging for me to hack on it. I think I don't=20
> need=3D=20
>>=3D20=20
>>> the=3D20=20
>>> > "Unapplied" column but am not sure. Even just some hints would be=20
> reall=3D=20
>> y=3D20=20
>>> > helpful.=3D20=20
>>> >=20
>>> > Thank you in advance!=20
>>> > Chris=20
>>> >=20
>>>=20
>>> fin=20
>>>=20
>>>=20
>>=20
>> --=3D20=20
>> You received this message because you are subscribed to the Google Groups=
>=20
> "=3D=20
>> Beancount" group.=20
>> To unsubscribe from this group and stop receiving emails from it, send an=
>=20
> e=3D=20
>> mail to beancount+...@googlegroups.com.=20
>> To view this discussion on the web visit=20
> https://groups.google.com/d/msgid/=3D=20
>> beancount/e11cdcaf-4c1b-4154-a731-76cd805b3482n%40googlegroups.com.=20
>>=20
>> ------=3D_Part_4969_1824196410.1702208487217=20
>> Content-Type: text/html; charset=3D"UTF-8"=20
>> Content-Transfer-Encoding: quoted-printable=20
>>=20
>><div>Well I was able to use LibreOffice to easily pre-format the CSV file=
>=20
> t=3D=20
>> o make things a little easier for me with the import code, but no luck=20
> yet.=3D=20
>><br /></div><div><br /></div><div>Updated file format looks like this:<br=
>=20
> /=3D=20
>>></div><div><br /></div><div><div><span cellspacing=3D3D"0"=20
> border=3D3D"0"><spa=3D=20
>> n><span><span height=3D3D"17"=20
> align=3D3D"left"></span></span></span></span></di=3D=20
>> v><div><span cellspacing=3D3D"0" border=3D3D"0"><span><span><span=20
> height=3D3D"17"=3D=20
>>=20
> align=3D3D"left">Date</span>=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=
>=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3D=20
>>=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0 <span align=3D3D"left">Descriptio=
> n</span>=3DC2=3DA0=3DC2=3D=20
>>=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0 <span=20
> align=3D3D"left">Amount</span>=3D=20
>>=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC=
> 2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3D=20
>
>>=3DA0 <span align=3D3D"left">Balance</span>=20
>> </span>=20
>> <span>=20
>> <span height=3D3D"17"=20
> align=3D3D"left"></span></span></span></span></div><div=3D=20
>>><span cellspacing=3D3D"0" border=3D3D"0"><span><span><span height=3D3D"17=
> "=20
> align=3D=20
>>=3D3D"left"></span></span></span></span></div><div><span cellspacing=3D3D"=
> 0"=20
> bo=3D=20
>> rder=3D3D"0"><span><span><span height=3D3D"17"=20
> align=3D3D"left"></span></span></s=3D=20
>> pan></span></div><div><span cellspacing=3D3D"0"=20
> border=3D3D"0"><span><span><spa=3D=20
>> n height=3D3D"17"=20
> align=3D3D"left">12/1/23=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=
>=3DC2=3DA0 =3D=20
>></span></span></span></span><span cellspacing=3D3D"0"=20
> border=3D3D"0"><span><spa=3D=20
>> n><span align=3D3D"left">PAYMENT=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=
>=3DC2=3DA0 =3DC2=3DA0=20
>=3DC2=3DA0 =3D=20
>></span></span></span></span><span cellspacing=3D3D"0"=20
> border=3D3D"0"><span><spa=3D=20
>> n><span=20
> align=3D3D"left">$951.28</span></span></span></span>=3DC2=3DA0=3DC2=3DA0=3D=
> C2=3D=20
>>=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA=
> 0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0 <span=20
> cells=3D=20
>> pacing=3D3D"0" border=3D3D"0"><span><span><span=20
> align=3D3D"left">$25,000.62</span=3D=20
>>></span></span></span></div><div><br /><span cellspacing=3D3D"0"=20
> border=3D3D"0"=3D=20
>>><span><span><span=20
> align=3D3D"left"></span></span></span></span></div><div><s=3D=20
>> pan cellspacing=3D3D"0" border=3D3D"0"><span><span><span=20
> align=3D3D"left">Updated=3D=20
>> import code looks like this:</span></span></span></span></div><div><span=
>=20
> c=3D=20
>> ellspacing=3D3D"0" border=3D3D"0"><span><span><span align=3D3D"left"><br=
>=20
> /></span=3D=20
>>></span></span></span></div><div><span><span>```</span></span></div><div>f=
> r=3D=20
>
>> om beancount_reds_importers.libreader import csvreader<br />from=20
> beancount_=3D=20
>> reds_importers.libtransactionbuilder import banking<br /><br />class=20
> Import=3D=20
>> er(csvreader.Importer, banking.Importer):<br />=3DC2=3DA0 =3DC2=3DA0=20
> IMPORTER_NAME =3D=20
>>=3D3D 'chasemortgage'</div><div><br /></div><div>=3DC2=3DA0 =3DC2=3DA0 def=
>=20
> custom_ini=3D=20
>> t(self):<br />=3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 self.max_roundi=
> ng_error =3D3D=20
> 0.04<=3D=20
>> br />=3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 self.filename_pattern_de=
> f =3D3D=20
> '*chase.com.=3D=20
>> csv'<br />=3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 self.header_identif=
> ier =3D3D=20
> 'Date,Desc=3D=20
>> ription,Amount,Balance'<br />=3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =
> self.date_format=20
>=3D=20
>>=3D3D '%x'<br />=3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 self.header_ma=
> p =3D3D {<br=20
> />=3DC2=3DA0=3D=20
>> =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 "Description": 'pa=
> yee',<br />=3DC2=3DA0=20
>=3DC2=3D=20
>>=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 "Date": =3DC2=3DA0 =3DC2=
>=3DA0 =3DC2=3DA0 =3DC2=3DA0=3DC2=3DA0=3D=20
>>=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0 'date',<br />=3DC2=3DA0 =3DC2=3DA0 =3DC2=3D=
> A0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0=20
> "=3D=20
>> Amount": =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 'amount',<br />=3DC2=3DA0 =3DC2=
>=3DA0 =3DC2=3DA0 =3DC2=3DA0=20
>=3D=20
>>=3DC2=3DA0 =3DC2=3DA0 "Balance:": =3DC2=3DA0 =3DC2=3DA0=3DC2=3DA0 'balance=
> ',<br />=3DC2=3DA0=20
>=3DC2=3DA0=3D=20
>> =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0=20
> }</div><div><span><span>```</span></span></div=3D=20
>>><div><br /></div><div>I'm getting this error in the=20
> terminal:</div><div><b=3D=20
>> r /></div><div>ERROR:root:Importer=20
> importers.chasemortgage.Importer.identif=3D=20
>> y() raised an unexpected error: nothing to repeat at position=20
> 0</div><div><=3D=20
>> br /></div><div>I have tried with and without the balance function tacked=
>=20
> o=3D=20
>> nto the end but am getting the same error so I think its unrelated to=20
> that.=3D=20
>><br /></div><div><br /></div><div>Any ideas on what to try next?=20
> Thanks!</d=3D=20
>> iv><div><br /></div></div><div class=3D3D"gmail_quote"><div dir=3D3D"auto=
> "=20
> clas=3D=20
>> s=3D3D"gmail_attr">On Friday, December 8, 2023 at 9:13:34=3DE2=3D80=3DAFP=
> M UTC-5=20
> fi=3D=20
>> n wrote:<br/></div><blockquote class=3D3D"gmail_quote" style=3D3D"margin:=
> 0 0=20
> 0=3D=20
>> 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left:=20
> 1ex;">Chri=3D=20
>> s Bond wrote:=20
>><br>&gt; ------=3D3D_Part_10662_427767134.1701975257612=20
>><br>&gt; Content-Type: multipart/alternative;=3D20=20
>><br>&gt;=20
> boundary=3D3D&quot;----=3D3D_Part_10663_1945899272.1701975257612&quot=3D=20
>> ;=20
>><br>&gt;=20
>><br>&gt; ------=3D3D_Part_10663_1945899272.1701975257612=20
>><br>&gt; Content-Type: text/plain; charset=3D3D&quot;UTF-8&quot;=20
>><br>&gt;=20
>><br>&gt; I have what I think may be a very simple CSV file:=20
>><br>&gt;=20
>><br>&gt; Column headers are these:=20
>><br>&gt; Date,Description,Amount,Unapplied,Balance=3D20=20
>><br>&gt;=20
>><br>&gt; Corresponding data fields look like this:=20
>><br>&gt; Dec 1, 2023,PAYMENT,$951.28,$951.28,$25,000.62=20
>><br>=20
>><br> you have a comma in the first field, you don&#39;t want to use=20
>><br>dates with commas in them if you are using csv format.=20
>><br>=20
>><br> sorry i don&#39;t have the time to look into this further but=20
>><br>i noticed this and thought it worth a comment. :)=20
>><br>=20
>><br> good luck,=20
>><br>=20
>><br> keep on trying, i learned a lot by doing a lot of=3D20=20
>><br>experiments and writing my own importers.=20
>><br>=20
>><br>=20
>><br>&gt; I have had some success using Red&#39;s ofx importer framework,=
>=20
> bu=3D=20
>> t am really=3D20=20
>><br>&gt; struggling to figure out the CSV importer from the examples in=20
> the=3D=20
>> git=3D20=20
>><br>&gt; repo. I started with the Discover example that looks like this:=
>=20
>><br>&gt;=20
>><br>&gt; from beancount_reds_importers.libreader import csvreader=20
>><br>&gt; from beancount_reds_importers.libtransactionbuilder import=20
> banking=20
>><br>&gt;=20
>><br>&gt; class Importer(csvreader.Importer, banking.Importer):=20
>><br>&gt; IMPORTER_NAME =3D3D &quot;&quot;&quot; Discover credit card .csv=
>=3D=20
>> importer.&quot;&quot;&quot;=20
>><br>&gt;=20
>><br>&gt; def custom_init(self):=20
>><br>&gt; self.max_rounding_error =3D3D 0.04=20
>><br>&gt; self.filename_pattern_def =3D3D &#39;Discover.*&#39;=20
>><br>&gt; self.header_identifier =3D3D &#39;Trans. Date,Post=3D20=20
>><br>&gt; Date,Description,Amount,Category&#39;=20
>><br>&gt; self.date_format =3D3D &#39;%m/%d/%Y&#39;=20
>><br>&gt; self.header_map =3D3D {=20
>><br>&gt; &quot;Category&quot;: &#39;payee&#39;,=20
>><br>&gt; &quot;Description&quot;: &#39;memo&#39;,=20
>><br>&gt; &quot;Trans. Date&quot;: &#39;date&#39;,=20
>><br>&gt; &quot;Post Date&quot;: &#39;postDate&#39;,=20
>><br>&gt; &quot;Amount&quot;: &#39;amount&#39;,=20
>><br>&gt; }=20
>><br>&gt;=20
>><br>&gt; def skip_transaction(self, ot):=20
>><br>&gt; return False=20
>><br>&gt;=20
>><br>&gt; def prepare_processed_table(self, rdr):=20
>><br>&gt; # Need to invert numbers supplied by Discover=20
>><br>&gt; rdr =3D3D rdr.convert(&#39;amount&#39;, lambda x: -1 * x)=20
>><br>&gt; return rdr=20
>><br>&gt;=20
>><br>&gt; I&#39;m pretty sure I don&#39;t need the def=20
> skip_transaction(self=3D=20
>> , ot) and def=3D20=20
>><br>&gt; prepare_processed_table(self, rdr): bits, but am at a loss to=20
> figu=3D=20
>> re out=3D20=20
>><br>&gt; what fields I need to modify in the def custom_init(self) for my=
>=20
> s=3D=20
>> ituation.=3D20=20
>><br>&gt; There is not an example CSV file for that importer in the repo so=
>=20
>=3D=20
>> it makes=3D20=20
>><br>&gt; it a little more challenging for me to hack on it. I think I=20
> don&#=3D=20
>> 39;t need the=3D20=20
>><br>&gt; &quot;Unapplied&quot; column but am not sure. Even just some=20
> hints=3D=20
>> would be really=3D20=20
>><br>&gt; helpful.=3D20=20
>><br>&gt;=20
>><br>&gt; Thank you in advance!=20
>><br>&gt; Chris=20
>><br>&gt;=20
>><br>=20
>><br> fin=20
>><br>=20
>><br></blockquote></div>=20
>>=20
>><p></p>=20
>>=20
>> -- <br />=20
>> You received this message because you are subscribed to the Google Groups=
>=20
> &=3D=20
>> quot;Beancount&quot; group.<br />=20
>> To unsubscribe from this group and stop receiving emails from it, send an=
>=20
> e=3D=20
>> mail to <a href=3D3D"mailto:beancount+...@googlegroups.com">beancount=3D=
>=20
>> +unsub...@googlegroups.com</a>.<br />=20
>> To view this discussion on the web visit <a href=3D3D"
> https://groups.google.c=3D=20
>>=20
> om/d/msgid/beancount/e11cdcaf-4c1b-4154-a731-76cd805b3482n%40googlegroups.c=
>=3D=20
>
>> om?utm_medium=3D3Demail&utm_source=3D3Dfooter">
> https://groups.google.com/d/msgi=3D=20
>> d/beancount/e11cdcaf-4c1b-4154-a731-76cd805b3482n%40googlegroups.com</a>.=
><b=3D=20
>
>> r />=20
>>=20
>> ------=3D_Part_4969_1824196410.1702208487217--=20
>>=20
>> ------=3D_Part_4968_1593684340.1702208487217--=20
>>=20
>
> --=20
> 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 e=
> mail to beancount+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/=
> beancount/494fa7c0-68e4-4f02-a4b0-27b52326cbe3n%40googlegroups.com.
>
> ------=_Part_4423_2068436066.1702256755797
> Content-Type: text/html; charset="UTF-8"
> Content-Transfer-Encoding: quoted-printable
>
><div>Sorry for my typo in previous post. Here is everything I have right no=
> w in the CSV file:</div><div><br /></div><div><div><span cellspacing=3D"0" =
> border=3D"0"><span><span><span height=3D"17" align=3D"left">Date</span>,<sp=
> an align=3D"left">Description</span>,<span align=3D"left">Amount,</span><sp=
> an align=3D"left">Balance</span>
> </span>
> <span>
> <span height=3D"17" align=3D"left"></span></span></span></span></div><div=
>><span cellspacing=3D"0" border=3D"0"><span><span><span height=3D"17" align=
>=3D"left"></span></span></span></span></div><div><span cellspacing=3D"0" bo=
> rder=3D"0"><span><span><span height=3D"17" align=3D"left"></span></span></s=
> pan></span></div><div><span cellspacing=3D"0" border=3D"0"><span><span><spa=
> n height=3D"17" align=3D"left">12/1/23,</span></span></span></span><span ce=
> llspacing=3D"0" border=3D"0"><span><span><span align=3D"left">PAYMENT,</spa=
> n></span></span></span><span cellspacing=3D"0" border=3D"0"><span><span><sp=
> an align=3D"left">951.28</span></span></span></span>,<span cellspacing=3D"0=
> " border=3D"0"><span><span><span align=3D"left">25000.62</span></span></spa=
> n></span></div><div><span cellspacing=3D"0" border=3D"0"><span><span><span =
> align=3D"left"><br /></span></span></span></span></div><div><span cellspaci=
> ng=3D"0" border=3D"0"><span><span><span align=3D"left">Here is my importer =
> code:<br /></span></span></span></span></div><div><span cellspacing=3D"0" b=
> order=3D"0"><span><span><span align=3D"left"><br /></span></span></span></s=
> pan></div><div><span cellspacing=3D"0" border=3D"0"><span><span><span align=
>=3D"left">```</span></span></span></span></div><div><div><div><div>from bea=
> ncount_reds_importers.libreader import csvreader<br />from beancount_reds_i=
> mporters.libtransactionbuilder import banking<br /><br />class Importer(csv=
> reader.Importer, banking.Importer):<br /></div></div></div><div><div>=C2=A0=
> =C2=A0 IMPORTER_NAME =3D 'chasemortgage'</div><div><br /></div><div></div>=
></div><div><div><div>=C2=A0 =C2=A0 def custom_init(self):<br />=C2=A0 =C2=
>=A0 =C2=A0 =C2=A0 self.max_rounding_error =3D 0.04<br /></div></div></div><=
> div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.filename_pattern_def =3D '*chase.=
> com.csv'<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.header_identifier =3D 'Date,=
> Description,Amount,Balance'<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.date_form=
> at =3D '%x'</div></div><div><div><div><br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 sel=
> f.header_map =3D {<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Date": =
>=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 'date',</div><div>=C2=
>=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "Descriptio=
> n": 'payee',<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Amount": =C2=
>=A0 =C2=A0 =C2=A0 'amount',<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
> "Balance:": =C2=A0 =C2=A0=C2=A0 'balance',<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0=
> =C2=A0 =C2=A0 }</div><div>```<br /></div></div></div></div></div><div><br =
> /></div><div>I just keep getting "ERROR:root:Importer importers.chasemortga=
> ge.Importer.identify() raised an unexpected error: nothing to repeat at pos=
> ition 0" and really have no idea what that means. Any additional thoughts w=
> ould be very welcome!<br /></div><div><br /></div><div><br /></div><div><di=
> v dir=3D"auto">On Sunday, December 10, 2023 at 1:12:19=E2=80=AFPM UTC-5 fin=
> wrote:<br /></div><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-l=
> eft: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Chris Bond wrote:
><br />&gt; ------=3D_Part_4968_1593684340.1702208487217
><br />&gt; Content-Type: multipart/alternative;=20
><br />&gt; boundary=3D"----=3D_Part_4969_1824196410.1702208487217"
><br />&gt;
><br />&gt; ------=3D_Part_4969_1824196410.1702208487217
><br />&gt; Content-Type: text/plain; charset=3D"UTF-8"
><br />&gt; Content-Transfer-Encoding: quoted-printable
><br />&gt;
><br />&gt; Well I was able to use LibreOffice to easily pre-format the CSV =
> file to=3D20
><br />&gt; make things a little easier for me with the import code, but no =
> luck yet.
><br />&gt;
><br />&gt; Updated file format looks like this:
><br />&gt;
><br />&gt; Date Description Amount Balance=
>=3D20
><br />&gt; 12/1/23 PAYMENT $951.28 $25,000.62
><br />&gt;
><br />&gt; Updated import code looks like this:
><br />&gt;
><br />&gt; ```
><br />&gt; from beancount_reds_importers.libreader import csvreader
><br />&gt; from beancount_reds_importers.libtransactionbuilder import banki=
> ng
><br />&gt;
><br />&gt; class Importer(csvreader.Importer, banking.Importer):
><br />&gt; IMPORTER_NAME =3D3D 'chasemortgage'
><br />&gt;
><br />&gt; def custom_init(self):
><br />&gt; self.max_rounding_error =3D3D 0.04
><br />&gt; self.filename_pattern_def =3D3D '*chase.com.csv'
><br />&gt; self.header_identifier =3D3D 'Date,Description,Amount,Ba=
> lance'
><br />&gt; self.date_format =3D3D '%x'
><br />&gt; self.header_map =3D3D {
><br />&gt; "Description": 'payee',
><br />&gt; "Date": 'date',
><br />&gt; "Amount": 'amount',
><br />&gt; "Balance:": 'balance',
><br />&gt; }
><br />&gt; ```
><br />
><br /> you have description before date, but in your data
><br />the date comes first.
><br />
><br /> also, with csv the fields should be separated by
><br />commas, but i see no field separators, and again you
><br />have a comma in a field which will throw things off
><br />unless the data is surrounded by quotation marks and
><br />your importer is looking for matched quotation marks
><br />(not all will allow commas anywhere else no matter
><br />what so that's up to you to fix or test).
><br />
><br /> i stop here with my comments because if you don't
><br />have the format and field names correct than anything
><br />else is going to likely not work well...
><br />
><br />
><br /> fin
><br />
><br />
><br />&gt; I'm getting this error in the terminal:
><br />&gt;
><br />&gt; ERROR:root:Importer importers.chasemortgage.Importer.identify() =
> raised an=3D
><br />&gt;=3D20
><br />&gt; unexpected error: nothing to repeat at position 0
><br />&gt;
><br />&gt; I have tried with and without the balance function tacked onto t=
> he end but=3D
><br />&gt;=3D20
><br />&gt; am getting the same error so I think its unrelated to that.
><br />&gt;
><br />&gt; Any ideas on what to try next? Thanks!
><br />&gt;
><br />&gt; On Friday, December 8, 2023 at 9:13:34=3DE2=3D80=3DAFPM UTC-5 fi=
> n wrote:
><br />&gt;
><br />&gt;&gt; Chris Bond wrote:
><br />&gt;&gt; &gt; ------=3D3D_Part_10662_427767134.1701975257612
><br />&gt;&gt; &gt; Content-Type: multipart/alternative;=3D20
><br />&gt;&gt; &gt; boundary=3D3D"----=3D3D_Part_10663_1945899272.170197525=
> 7612"
><br />&gt;&gt; &gt;
><br />&gt;&gt; &gt; ------=3D3D_Part_10663_1945899272.1701975257612
><br />&gt;&gt; &gt; Content-Type: text/plain; charset=3D3D"UTF-8"
><br />&gt;&gt; &gt;
><br />&gt;&gt; &gt; I have what I think may be a very simple CSV file:
><br />&gt;&gt; &gt;
><br />&gt;&gt; &gt; Column headers are these:
><br />&gt;&gt; &gt; Date,Description,Amount,Unapplied,Balance=3D20
><br />&gt;&gt; &gt;
><br />&gt;&gt; &gt; Corresponding data fields look like this:
><br />&gt;&gt; &gt; Dec 1, 2023,PAYMENT,$951.28,$951.28,$25,000.62
><br />&gt;&gt;
><br />&gt;&gt; you have a comma in the first field, you don't want to use
><br />&gt;&gt; dates with commas in them if you are using csv format.
><br />&gt;&gt;
><br />&gt;&gt; sorry i don't have the time to look into this further but
><br />&gt;&gt; i noticed this and thought it worth a comment. :)
><br />&gt;&gt;
><br />&gt;&gt; good luck,
><br />&gt;&gt;
><br />&gt;&gt; keep on trying, i learned a lot by doing a lot of=3D20
><br />&gt;&gt; experiments and writing my own importers.
><br />&gt;&gt;
><br />&gt;&gt;
><br />&gt;&gt; &gt; I have had some success using Red's ofx importer framew=
> ork, but am=3D20
><br />&gt;&gt; really=3D20
><br />&gt;&gt; &gt; struggling to figure out the CSV importer from the exam=
> ples in the git=3D
><br />&gt;=3D20
><br />&gt;&gt; &gt; repo. I started with the Discover example that looks li=
> ke this:
><br />&gt;&gt; &gt;
><br />&gt;&gt; &gt; from beancount_reds_importers.libreader import csvreade=
> r
><br />&gt;&gt; &gt; from beancount_reds_importers.libtransactionbuilder imp=
> ort banking
><br />&gt;&gt; &gt;
><br />&gt;&gt; &gt; class Importer(csvreader.Importer, banking.Importer):
><br />&gt;&gt; &gt; IMPORTER_NAME =3D3D """ Discover credit card .csv impor=
> ter."""
><br />&gt;&gt; &gt;
><br />&gt;&gt; &gt; def custom_init(self):
><br />&gt;&gt; &gt; self.max_rounding_error =3D3D 0.04
><br />&gt;&gt; &gt; self.filename_pattern_def =3D3D 'Discover.*'
><br />&gt;&gt; &gt; self.header_identifier =3D3D 'Trans. Date,Post=3D20
><br />&gt;&gt; &gt; Date,Description,Amount,Category'
><br />&gt;&gt; &gt; self.date_format =3D3D '%m/%d/%Y'
><br />&gt;&gt; &gt; self.header_map =3D3D {
><br />&gt;&gt; &gt; "Category": 'payee',
><br />&gt;&gt; &gt; "Description": 'memo',
><br />&gt;&gt; &gt; "Trans. Date": 'date',
><br />&gt;&gt; &gt; "Post Date": 'postDate',
><br />&gt;&gt; &gt; "Amount": 'amount',
><br />&gt;&gt; &gt; }
><br />&gt;&gt; &gt;
><br />&gt;&gt; &gt; def skip_transaction(self, ot):
><br />&gt;&gt; &gt; return False
><br />&gt;&gt; &gt;
><br />&gt;&gt; &gt; def prepare_processed_table(self, rdr):
><br />&gt;&gt; &gt; # Need to invert numbers supplied by Discover
><br />&gt;&gt; &gt; rdr =3D3D rdr.convert('amount', lambda x: -1 * x)
><br />&gt;&gt; &gt; return rdr
><br />&gt;&gt; &gt;
><br />&gt;&gt; &gt; I'm pretty sure I don't need the def skip_transaction(s=
> elf, ot) and def=3D
><br />&gt;=3D20
><br />&gt;&gt; &gt; prepare_processed_table(self, rdr): bits, but am at a l=
> oss to figure ou=3D
><br />&gt; t=3D20
><br />&gt;&gt; &gt; what fields I need to modify in the def custom_init(sel=
> f) for my=3D20
><br />&gt;&gt; situation.=3D20
><br />&gt;&gt; &gt; There is not an example CSV file for that importer in t=
> he repo so it=3D20
><br />&gt;&gt; makes=3D20
><br />&gt;&gt; &gt; it a little more challenging for me to hack on it. I th=
> ink I don't need=3D
><br />&gt;=3D20
><br />&gt;&gt; the=3D20
><br />&gt;&gt; &gt; "Unapplied" column but am not sure. Even just some hint=
> s would be reall=3D
><br />&gt; y=3D20
><br />&gt;&gt; &gt; helpful.=3D20
><br />&gt;&gt; &gt;
><br />&gt;&gt; &gt; Thank you in advance!
><br />&gt;&gt; &gt; Chris
><br />&gt;&gt; &gt;
><br />&gt;&gt;
><br />&gt;&gt; fin
><br />&gt;&gt;
><br />&gt;&gt;
><br />&gt;
><br />&gt; --=3D20
><br />&gt; You received this message because you are subscribed to the Goog=
> le Groups "=3D
><br />&gt; Beancount" group.
><br />&gt; To unsubscribe from this group and stop receiving emails from it=
> , send an e=3D
><br />&gt; mail to <a href=3D"" rel=3D"nofollow">beancount+...@googlegroups=
> .com</a>.
><br />&gt; To view this discussion on the web visit <a href=3D"https://grou=
> ps.google.com/d/msgid/=3D" target=3D"_blank" rel=3D"nofollow">https://group=
> s.google.com/d/msgid/=3D</a>
><br />&gt; beancount/e11cdcaf-4c1b-4154-a731-76cd805b3482n%<a href=3D"http:=
> //40googlegroups.com" target=3D"_blank" rel=3D"nofollow">40googlegroups.com=
></a>.
><br />&gt;
><br />&gt; ------=3D_Part_4969_1824196410.1702208487217
><br />&gt; Content-Type: text/html; charset=3D"UTF-8"
><br />&gt; Content-Transfer-Encoding: quoted-printable
><br />&gt;
><br />&gt;&lt;div&gt;Well I was able to use LibreOffice to easily pre-forma=
> t the CSV file t=3D
><br />&gt; o make things a little easier for me with the import code, but n=
> o luck yet.=3D
><br />&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;di=
> v&gt;Updated file format looks like this:&lt;br /=3D
><br />&gt;&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt=
> ;div&gt;&lt;span cellspacing=3D3D"0" border=3D3D"0"&gt;&lt;spa=3D
><br />&gt; n&gt;&lt;span&gt;&lt;span height=3D3D"17" align=3D3D"left"&gt;&l=
> t;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/di=3D
><br />&gt; v&gt;&lt;div&gt;&lt;span cellspacing=3D3D"0" border=3D3D"0"&gt;&=
> lt;span&gt;&lt;span&gt;&lt;span height=3D3D"17"=3D
><br />&gt; align=3D3D"left"&gt;Date&lt;/span&gt;=3DC2=3DA0=3DC2=3DA0=3DC2=
>=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3D
><br />&gt;=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0 &lt;span align=3D3D"left=
> "&gt;Description&lt;/span&gt;=3DC2=3DA0=3DC2=3D
><br />&gt;=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=
> &lt;span align=3D3D"left"&gt;Amount&lt;/span&gt;=3D
><br />&gt;=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=
>=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3D
><br />&gt;=3DA0 &lt;span align=3D3D"left"&gt;Balance&lt;/span&gt;
><br />&gt; &lt;/span&gt;
><br />&gt; &lt;span&gt;
><br />&gt; &lt;span height=3D3D"17" align=3D3D"left"&gt;&lt;/span&gt;&lt;=
> /span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div=3D
><br />&gt;&gt;&lt;span cellspacing=3D3D"0" border=3D3D"0"&gt;&lt;span&gt;&l=
> t;span&gt;&lt;span height=3D3D"17" align=3D
><br />&gt;=3D3D"left"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&g=
> t;&lt;/div&gt;&lt;div&gt;&lt;span cellspacing=3D3D"0" bo=3D
><br />&gt; rder=3D3D"0"&gt;&lt;span&gt;&lt;span&gt;&lt;span height=3D3D"17"=
> align=3D3D"left"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/s=3D
><br />&gt; pan&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span cellspacing=
>=3D3D"0" border=3D3D"0"&gt;&lt;span&gt;&lt;span&gt;&lt;spa=3D
><br />&gt; n height=3D3D"17" align=3D3D"left"&gt;12/1/23=3DC2=3DA0=3DC2=3DA=
> 0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0 =3D
><br />&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span cell=
> spacing=3D3D"0" border=3D3D"0"&gt;&lt;span&gt;&lt;spa=3D
><br />&gt; n&gt;&lt;span align=3D3D"left"&gt;PAYMENT=3DC2=3DA0=3DC2=3DA0=3D=
> C2=3DA0=3DC2=3DA0=3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3D
><br />&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span cell=
> spacing=3D3D"0" border=3D3D"0"&gt;&lt;span&gt;&lt;spa=3D
><br />&gt; n&gt;&lt;span align=3D3D"left"&gt;$951.28&lt;/span&gt;&lt;/span&=
> gt;&lt;/span&gt;&lt;/span&gt;=3DC2=3DA0=3DC2=3DA0=3DC2=3D
><br />&gt;=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=
>=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0 &lt;span cells=3D
><br />&gt; pacing=3D3D"0" border=3D3D"0"&gt;&lt;span&gt;&lt;span&gt;&lt;spa=
> n align=3D3D"left"&gt;$25,000.62&lt;/span=3D
><br />&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt=
> ;&lt;br /&gt;&lt;span cellspacing=3D3D"0" border=3D3D"0"=3D
><br />&gt;&gt;&lt;span&gt;&lt;span&gt;&lt;span align=3D3D"left"&gt;&lt;/spa=
> n&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;s=3D
><br />&gt; pan cellspacing=3D3D"0" border=3D3D"0"&gt;&lt;span&gt;&lt;span&g=
> t;&lt;span align=3D3D"left"&gt;Updated=3D
><br />&gt; import code looks like this:&lt;/span&gt;&lt;/span&gt;&lt;/span=
> &gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span c=3D
><br />&gt; ellspacing=3D3D"0" border=3D3D"0"&gt;&lt;span&gt;&lt;span&gt;&lt=
> ;span align=3D3D"left"&gt;&lt;br /&gt;&lt;/span=3D
><br />&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt=
> ;&lt;span&gt;&lt;span&gt;```&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&g=
> t;fr=3D
><br />&gt; om beancount_reds_importers.libreader import csvreader&lt;br /&g=
> t;from beancount_=3D
><br />&gt; reds_importers.libtransactionbuilder import banking&lt;br /&gt;&=
> lt;br /&gt;class Import=3D
><br />&gt; er(csvreader.Importer, banking.Importer):&lt;br /&gt;=3DC2=3DA0 =
>=3DC2=3DA0 IMPORTER_NAME =3D
><br />&gt;=3D3D 'chasemortgage'&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&=
> gt;&lt;div&gt;=3DC2=3DA0 =3DC2=3DA0 def custom_ini=3D
><br />&gt; t(self):&lt;br /&gt;=3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =
> self.max_rounding_error =3D3D 0.04&lt;=3D
><br />&gt; br /&gt;=3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 self.filenam=
> e_pattern_def =3D3D '*chase.com.=3D
><br />&gt; csv'&lt;br /&gt;=3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 self=
> .header_identifier =3D3D 'Date,Desc=3D
><br />&gt; ription,Amount,Balance'&lt;br /&gt;=3DC2=3DA0 =3DC2=3DA0 =3DC2=
>=3DA0 =3DC2=3DA0 self.date_format =3D
><br />&gt;=3D3D '%x'&lt;br /&gt;=3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0=
> self.header_map =3D3D {&lt;br /&gt;=3DC2=3DA0=3D
><br />&gt; =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 "Descript=
> ion": 'payee',&lt;br /&gt;=3DC2=3DA0 =3DC2=3D
><br />&gt;=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 "Date": =3DC2=
>=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0=3DC2=3DA0=3D
><br />&gt;=3DC2=3DA0=3DC2=3DA0=3DC2=3DA0 'date',&lt;br /&gt;=3DC2=3DA0 =3DC=
> 2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 "=3D
><br />&gt; Amount": =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 'amount',&lt;br /&gt;=
>=3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3D
><br />&gt;=3DC2=3DA0 =3DC2=3DA0 "Balance:": =3DC2=3DA0 =3DC2=3DA0=3DC2=3DA0=
> 'balance',&lt;br /&gt;=3DC2=3DA0 =3DC2=3DA0=3D
><br />&gt; =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 }&lt;/div&gt;&lt;div=
> &gt;&lt;span&gt;&lt;span&gt;```&lt;/span&gt;&lt;/span&gt;&lt;/div=3D
><br />&gt;&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I'm getting thi=
> s error in the terminal:&lt;/div&gt;&lt;div&gt;&lt;b=3D
><br />&gt; r /&gt;&lt;/div&gt;&lt;div&gt;ERROR:root:Importer importers.chas=
> emortgage.Importer.identif=3D
><br />&gt; y() raised an unexpected error: nothing to repeat at position 0&=
> lt;/div&gt;&lt;div&gt;&lt;=3D
><br />&gt; br /&gt;&lt;/div&gt;&lt;div&gt;I have tried with and without the=
> balance function tacked o=3D
><br />&gt; nto the end but am getting the same error so I think its unrelat=
> ed to that.=3D
><br />&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;di=
> v&gt;Any ideas on what to try next? Thanks!&lt;/d=3D
><br />&gt; iv&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div cla=
> ss=3D3D"gmail_quote"&gt;&lt;div dir=3D3D"auto" clas=3D
><br />&gt; s=3D3D"gmail_attr"&gt;On Friday, December 8, 2023 at 9:13:34=3DE=
> 2=3D80=3DAFPM UTC-5 fi=3D
><br />&gt; n wrote:&lt;br/&gt;&lt;/div&gt;&lt;blockquote class=3D3D"gmail_q=
> uote" style=3D3D"margin: 0 0 0=3D
><br />&gt; 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left:=
> 1ex;"&gt;Chri=3D
><br />&gt; s Bond wrote:
><br />&gt;&lt;br&gt;&amp;gt; ------=3D3D_Part_10662_427767134.1701975257612
><br />&gt;&lt;br&gt;&amp;gt; Content-Type: multipart/alternative;=3D20
><br />&gt;&lt;br&gt;&amp;gt; boundary=3D3D&amp;quot;----=3D3D_Part_10663_1=
> 945899272.1701975257612&amp;quot=3D
><br />&gt; ;
><br />&gt;&lt;br&gt;&amp;gt;
><br />&gt;&lt;br&gt;&amp;gt; ------=3D3D_Part_10663_1945899272.170197525761=
> 2
><br />&gt;&lt;br&gt;&amp;gt; Content-Type: text/plain; charset=3D3D&amp;quo=
> t;UTF-8&amp;quot;
><br />&gt;&lt;br&gt;&amp;gt;
><br />&gt;&lt;br&gt;&amp;gt; I have what I think may be a very simple CSV =
> file:
><br />&gt;&lt;br&gt;&amp;gt;
><br />&gt;&lt;br&gt;&amp;gt; Column headers are these:
><br />&gt;&lt;br&gt;&amp;gt; Date,Description,Amount,Unapplied,Balance=3D20
><br />&gt;&lt;br&gt;&amp;gt;
><br />&gt;&lt;br&gt;&amp;gt; Corresponding data fields look like this:
><br />&gt;&lt;br&gt;&amp;gt; Dec 1, 2023,PAYMENT,$951.28,$951.28,$25,000.62
><br />&gt;&lt;br&gt;
><br />&gt;&lt;br&gt; you have a comma in the first field, you don&amp;#39;=
> t want to use
><br />&gt;&lt;br&gt;dates with commas in them if you are using csv format.
><br />&gt;&lt;br&gt;
><br />&gt;&lt;br&gt; sorry i don&amp;#39;t have the time to look into this=
> further but
><br />&gt;&lt;br&gt;i noticed this and thought it worth a comment. :)
><br />&gt;&lt;br&gt;
><br />&gt;&lt;br&gt; good luck,
><br />&gt;&lt;br&gt;
><br />&gt;&lt;br&gt; keep on trying, i learned a lot by doing a lot of=3D2=
> 0
><br />&gt;&lt;br&gt;experiments and writing my own importers.
><br />&gt;&lt;br&gt;
><br />&gt;&lt;br&gt;
><br />&gt;&lt;br&gt;&amp;gt; I have had some success using Red&amp;#39;s of=
> x importer framework, bu=3D
><br />&gt; t am really=3D20
><br />&gt;&lt;br&gt;&amp;gt; struggling to figure out the CSV importer from=
> the examples in the=3D
><br />&gt; git=3D20
><br />&gt;&lt;br&gt;&amp;gt; repo. I started with the Discover example that=
> looks like this:
><br />&gt;&lt;br&gt;&amp;gt;
><br />&gt;&lt;br&gt;&amp;gt; from beancount_reds_importers.libreader import=
> csvreader
><br />&gt;&lt;br&gt;&amp;gt; from beancount_reds_importers.libtransactionbu=
> ilder import banking
><br />&gt;&lt;br&gt;&amp;gt;
><br />&gt;&lt;br&gt;&amp;gt; class Importer(csvreader.Importer, banking.Imp=
> orter):
><br />&gt;&lt;br&gt;&amp;gt; IMPORTER_NAME =3D3D &amp;quot;&amp;quot;&a=
> mp;quot; Discover credit card .csv=3D
><br />&gt; importer.&amp;quot;&amp;quot;&amp;quot;
><br />&gt;&lt;br&gt;&amp;gt;
><br />&gt;&lt;br&gt;&amp;gt; def custom_init(self):
><br />&gt;&lt;br&gt;&amp;gt; self.max_rounding_error =3D3D 0.04
><br />&gt;&lt;br&gt;&amp;gt; self.filename_pattern_def =3D3D &amp;#=
> 39;Discover.*&amp;#39;
><br />&gt;&lt;br&gt;&amp;gt; self.header_identifier =3D3D &amp;#39;=
> Trans. Date,Post=3D20
><br />&gt;&lt;br&gt;&amp;gt; Date,Description,Amount,Category&amp;#39;
><br />&gt;&lt;br&gt;&amp;gt; self.date_format =3D3D &amp;#39;%m/%d/=
> %Y&amp;#39;
><br />&gt;&lt;br&gt;&amp;gt; self.header_map =3D3D {
><br />&gt;&lt;br&gt;&amp;gt; &amp;quot;Category&amp;quot;: &=
> amp;#39;payee&amp;#39;,
><br />&gt;&lt;br&gt;&amp;gt; &amp;quot;Description&amp;quot;: &=
> amp;#39;memo&amp;#39;,
><br />&gt;&lt;br&gt;&amp;gt; &amp;quot;Trans. Date&amp;quot;: &=
> amp;#39;date&amp;#39;,
><br />&gt;&lt;br&gt;&amp;gt; &amp;quot;Post Date&amp;quot;: &=
> amp;#39;postDate&amp;#39;,
><br />&gt;&lt;br&gt;&amp;gt; &amp;quot;Amount&amp;quot;: &=
> amp;#39;amount&amp;#39;,
><br />&gt;&lt;br&gt;&amp;gt; }
><br />&gt;&lt;br&gt;&amp;gt;
><br />&gt;&lt;br&gt;&amp;gt; def skip_transaction(self, ot):
><br />&gt;&lt;br&gt;&amp;gt; return False
><br />&gt;&lt;br&gt;&amp;gt;
><br />&gt;&lt;br&gt;&amp;gt; def prepare_processed_table(self, rdr):
><br />&gt;&lt;br&gt;&amp;gt; # Need to invert numbers supplied by D=
> iscover
><br />&gt;&lt;br&gt;&amp;gt; rdr =3D3D rdr.convert(&amp;#39;amount&=
> amp;#39;, lambda x: -1 * x)
><br />&gt;&lt;br&gt;&amp;gt; return rdr
><br />&gt;&lt;br&gt;&amp;gt;
><br />&gt;&lt;br&gt;&amp;gt; I&amp;#39;m pretty sure I don&amp;#39;t need t=
> he def skip_transaction(self=3D
><br />&gt; , ot) and def=3D20
><br />&gt;&lt;br&gt;&amp;gt; prepare_processed_table(self, rdr): bits, but =
> am at a loss to figu=3D
><br />&gt; re out=3D20
><br />&gt;&lt;br&gt;&amp;gt; what fields I need to modify in the def custom=
> _init(self) for my s=3D
><br />&gt; ituation.=3D20
><br />&gt;&lt;br&gt;&amp;gt; There is not an example CSV file for that impo=
> rter in the repo so =3D
><br />&gt; it makes=3D20
><br />&gt;&lt;br&gt;&amp;gt; it a little more challenging for me to hack on=
> it. I think I don&amp;#=3D
><br />&gt; 39;t need the=3D20
><br />&gt;&lt;br&gt;&amp;gt; &amp;quot;Unapplied&amp;quot; column but am no=
> t sure. Even just some hints=3D
><br />&gt; would be really=3D20
><br />&gt;&lt;br&gt;&amp;gt; helpful.=3D20
><br />&gt;&lt;br&gt;&amp;gt;
><br />&gt;&lt;br&gt;&amp;gt; Thank you in advance!
><br />&gt;&lt;br&gt;&amp;gt; Chris
><br />&gt;&lt;br&gt;&amp;gt;
><br />&gt;&lt;br&gt;
><br />&gt;&lt;br&gt; fin
><br />&gt;&lt;br&gt;
><br />&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;/div&gt;
><br />&gt;
><br />&gt;&lt;p&gt;&lt;/p&gt;
><br />&gt;
><br />&gt; -- &lt;br /&gt;
><br />&gt; You received this message because you are subscribed to the Goog=
> le Groups &amp;=3D
><br />&gt; quot;Beancount&amp;quot; group.&lt;br /&gt;
><br />&gt; To unsubscribe from this group and stop receiving emails from it=
> , send an e=3D
><br />&gt; mail to &lt;a href=3D3D"mailto:<a href=3D"" rel=3D"nofollow">bea=
> ncount+...@googlegroups.com</a>"&gt;beancount=3D
><br />&gt; +<a href=3D"" rel=3D"nofollow">unsub...@googlegroups.com</a>&lt;=
> /a&gt;.&lt;br /&gt;
><br />&gt; To view this discussion on the web visit &lt;a href=3D3D"<a href=
>=3D"https://groups.google.c" target=3D"_blank" rel=3D"nofollow">https://gro=
> ups.google.c</a>=3D
><br />&gt; om/d/msgid/beancount/e11cdcaf-4c1b-4154-a731-76cd805b3482n%40goo=
> glegroups.c=3D
><br />&gt; om?utm_medium=3D3Demail&amp;utm_source=3D3Dfooter"&gt;<a href=3D=
> "https://groups.google.com/d/msgi=3D" target=3D"_blank" rel=3D"nofollow">ht=
> tps://groups.google.com/d/msgi=3D</a>
><br />&gt; d/beancount/e11cdcaf-4c1b-4154-a731-76cd805b3482n%<a href=3D"htt=
> p://40googlegroups.com" target=3D"_blank" rel=3D"nofollow">40googlegroups.c=
> om</a>&lt;/a&gt;.&lt;b=3D
><br />&gt; r /&gt;
><br />&gt;
><br />&gt; ------=3D_Part_4969_1824196410.1702208487217--
><br />&gt;
><br />&gt; ------=3D_Part_4968_1593684340.1702208487217--
><br />&gt;
><br />
><br /></blockquote></div>
>
><p></p>
>
> -- <br />
> You received this message because you are subscribed to the Google Groups &=
> quot;Beancount&quot; group.<br />
> To unsubscribe from this group and stop receiving emails from it, send an e=
> mail to <a href=3D"mailto:beancount+...@googlegroups.com">beancount=
> +unsub...@googlegroups.com</a>.<br />
> To view this discussion on the web visit <a href=3D"https://groups.google.c=
> om/d/msgid/beancount/494fa7c0-68e4-4f02-a4b0-27b52326cbe3n%40googlegroups.c=
> om?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgi=
> d/beancount/494fa7c0-68e4-4f02-a4b0-27b52326cbe3n%40googlegroups.com</a>.<b=
> r />
>
> ------=_Part_4423_2068436066.1702256755797--
>
> ------=_Part_4422_1215321251.1702256755797--
>

fin

unread,
Dec 13, 2023, 9:15:06 PM12/13/23
to bean...@googlegroups.com
p.s. sorry to not have had a chance to look at this recently.
i'm still in gardening season here for a while longer so i don't
get switched over to winter projects until the gardening is done.
i may not get a chance to get back here to look very often in
the meantime...


fin

Reply all
Reply to author
Forward
0 new messages