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!


On Sunday, December 10, 2023 at 1:12:19 PM UTC-5 fin wrote:

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-- 
> 

-- 
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/494fa7c0-68e4-4f02-a4b0-27b52326cbe3n%40googlegroups.com.

Reply via email to