Matching account by filename

2019-04-04 Thread Zhuoyun Wei
Hi,

the CSV importer determines the account to use by "regexps" parameter. I have 
two accounts from the same bank (one checking and one savings), and the CSV 
files of both are of the same format. There isn't anything in the file content 
that could tell the two accounts apart. The only difference is the file name 
(e.g. "Chase.csv" for checking, "Chase.csv" for savings).

Under this circumstance, "regexps" parameter does not work. How could I import 
different files into different accounts?

-- 
Zhuoyun Wei

-- 
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 post to this group, send email to beancount@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/17beda3b-4862-44e8-b839-51aaf6d573f8%40www.fastmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Matching account by filename

2019-04-04 Thread Aamer Abbas
You can't do it with the CSV importer the way it's currently written. You
will need to write your own importer.

Something like this, but obviously refactored in a nicer way.

def extract(self, file):
file_name = path.basename(file.name)

if file_name == "something.csv":
account = "Assets:US:Something"
elif file_name == "something_else.csv"
account = "Assets:US:SomethingElse"

On Thu, Apr 4, 2019 at 11:33 AM Zhuoyun Wei  wrote:

> Hi,
>
> the CSV importer determines the account to use by "regexps" parameter. I
> have two accounts from the same bank (one checking and one savings), and
> the CSV files of both are of the same format. There isn't anything in the
> file content that could tell the two accounts apart. The only difference is
> the file name (e.g. "Chase.csv" for checking, "Chase.csv" for
> savings).
>
> Under this circumstance, "regexps" parameter does not work. How could I
> import different files into different accounts?
>
> --
> Zhuoyun Wei
>
> --
> 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 post to this group, send email to beancount@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beancount/17beda3b-4862-44e8-b839-51aaf6d573f8%40www.fastmail.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 beancount+unsubscr...@googlegroups.com.
To post to this group, send email to beancount@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAOHSxbmevAEXa6UxooaXVWVWY-aRichwrd_uNCATxi0hcGNKZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Matching account by filename

2019-04-04 Thread Aamer Abbas
By the way, just wanted to note this is for extraction purposes since you
need to use a different account based on the file name. If it's only for
identification purposes, the identifier mixin already supports matching on
the file name (
https://bitbucket.org/blais/beancount/src/fa1edde3bcd02a277fac193f460a39c9a1461161/beancount/ingest/importers/mixins/identifier.py?at=default&fileviewer=file-view-default#identifier.py-32
)

On Thu, Apr 4, 2019 at 6:35 PM Aamer Abbas  wrote:

> You can't do it with the CSV importer the way it's currently written. You
> will need to write your own importer.
>
> Something like this, but obviously refactored in a nicer way.
>
> def extract(self, file):
> file_name = path.basename(file.name)
>
> if file_name == "something.csv":
> account = "Assets:US:Something"
> elif file_name == "something_else.csv"
> account = "Assets:US:SomethingElse"
>
> On Thu, Apr 4, 2019 at 11:33 AM Zhuoyun Wei  wrote:
>
>> Hi,
>>
>> the CSV importer determines the account to use by "regexps" parameter. I
>> have two accounts from the same bank (one checking and one savings), and
>> the CSV files of both are of the same format. There isn't anything in the
>> file content that could tell the two accounts apart. The only difference is
>> the file name (e.g. "Chase.csv" for checking, "Chase.csv" for
>> savings).
>>
>> Under this circumstance, "regexps" parameter does not work. How could I
>> import different files into different accounts?
>>
>> --
>> Zhuoyun Wei
>>
>> --
>> 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 post to this group, send email to beancount@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/beancount/17beda3b-4862-44e8-b839-51aaf6d573f8%40www.fastmail.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 beancount+unsubscr...@googlegroups.com.
To post to this group, send email to beancount@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAOHSxbnuC06TGuyP9C2a_1dZM_znUYfHuJMhSRNqjPByHc%3D7Lw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Matching account by filename

2019-04-05 Thread Zhuoyun Wei
Thanks. My current workflow is to use "bean-extract" to extract transactions 
from multiple CSV files downloaded from different institutions. I have been 
using this workflow for a few years, until recently I opened a savings account.

I will look into how to use the importer directly, instead of using 
"bean-extract".

-- 
Zhuoyun Wei

On Thu, Apr 4, 2019, at 11:38, Aamer Abbas wrote:
> By the way, just wanted to note this is for extraction purposes since 
> you need to use a different account based on the file name. If it's 
> only for identification purposes, the identifier mixin already supports 
> matching on the file name 
> (https://bitbucket.org/blais/beancount/src/fa1edde3bcd02a277fac193f460a39c9a1461161/beancount/ingest/importers/mixins/identifier.py?at=default&fileviewer=file-view-default#identifier.py-32)
> 
> On Thu, Apr 4, 2019 at 6:35 PM Aamer Abbas  wrote:
> > You can't do it with the CSV importer the way it's currently written. You 
> > will need to write your own importer. 
> > 
> > Something like this, but obviously refactored in a nicer way.
> > 
> >  def extract(self, file):
> >  file_name = path.basename(file.name)
> > 
> >  if file_name == "something.csv":
> >  account = "Assets:US:Something"
> >  elif file_name == "something_else.csv"
> >  account = "Assets:US:SomethingElse"
> > 
> > On Thu, Apr 4, 2019 at 11:33 AM Zhuoyun Wei  wrote:
> >> Hi,
> >> 
> >>  the CSV importer determines the account to use by "regexps" parameter. I 
> >> have two accounts from the same bank (one checking and one savings), and 
> >> the CSV files of both are of the same format. There isn't anything in the 
> >> file content that could tell the two accounts apart. The only difference 
> >> is the file name (e.g. "Chase.csv" for checking, "Chase.csv" for 
> >> savings).
> >> 
> >>  Under this circumstance, "regexps" parameter does not work. How could I 
> >> import different files into different accounts?
> >> 
> >>  -- 
> >>  Zhuoyun Wei
> >> 
> >>  -- 
> >>  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 post to this group, send email to beancount@googlegroups.com.
> >>  To view this discussion on the web visit 
> >> https://groups.google.com/d/msgid/beancount/17beda3b-4862-44e8-b839-51aaf6d573f8%40www.fastmail.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 beancount+unsubscr...@googlegroups.com.
>  To post to this group, send email to beancount@googlegroups.com.
>  To view this discussion on the web visit 
> https://groups.google.com/d/msgid/beancount/CAOHSxbnuC06TGuyP9C2a_1dZM_znUYfHuJMhSRNqjPByHc%3D7Lw%40mail.gmail.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 beancount+unsubscr...@googlegroups.com.
To post to this group, send email to beancount@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/3f414514-d832-407b-954a-2bc55be4a842%40www.fastmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Matching account by filename

2019-04-05 Thread Martin Blais
Customize the class to make identify() match on file.name rather than the
content and create two instances with different account names.

On Thu, Apr 4, 2019, 04:33 Zhuoyun Wei  wrote:

> Hi,
>
> the CSV importer determines the account to use by "regexps" parameter. I
> have two accounts from the same bank (one checking and one savings), and
> the CSV files of both are of the same format. There isn't anything in the
> file content that could tell the two accounts apart. The only difference is
> the file name (e.g. "Chase.csv" for checking, "Chase.csv" for
> savings).
>
> Under this circumstance, "regexps" parameter does not work. How could I
> import different files into different accounts?
>
> --
> Zhuoyun Wei
>
> --
> 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 post to this group, send email to beancount@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beancount/17beda3b-4862-44e8-b839-51aaf6d573f8%40www.fastmail.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 beancount+unsubscr...@googlegroups.com.
To post to this group, send email to beancount@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAK21%2BhPjt0zPY%3D07S5C8KXzkOHsAweJYzatFyXdS%3D2TtwXnyVQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Matching account by filename

2019-04-05 Thread Aamer Abbas
No problem. Just to be clear, your new importers should still work using
bean-extract. Your usage should remain identical - the only thing that will
change is the code that is used to do the extraction.

On Fri, Apr 5, 2019 at 10:06 AM Zhuoyun Wei  wrote:

> Thanks. My current workflow is to use "bean-extract" to extract
> transactions from multiple CSV files downloaded from different
> institutions. I have been using this workflow for a few years, until
> recently I opened a savings account.
>
> I will look into how to use the importer directly, instead of using
> "bean-extract".
>
> --
> Zhuoyun Wei
>
> On Thu, Apr 4, 2019, at 11:38, Aamer Abbas wrote:
> > By the way, just wanted to note this is for extraction purposes since
> > you need to use a different account based on the file name. If it's
> > only for identification purposes, the identifier mixin already supports
> > matching on the file name
> > (
> https://bitbucket.org/blais/beancount/src/fa1edde3bcd02a277fac193f460a39c9a1461161/beancount/ingest/importers/mixins/identifier.py?at=default&fileviewer=file-view-default#identifier.py-32
> )
> >
> > On Thu, Apr 4, 2019 at 6:35 PM Aamer Abbas  wrote:
> > > You can't do it with the CSV importer the way it's currently written.
> You will need to write your own importer.
> > >
> > > Something like this, but obviously refactored in a nicer way.
> > >
> > >  def extract(self, file):
> > >  file_name = path.basename(file.name)
> > >
> > >  if file_name == "something.csv":
> > >  account = "Assets:US:Something"
> > >  elif file_name == "something_else.csv"
> > >  account = "Assets:US:SomethingElse"
> > >
> > > On Thu, Apr 4, 2019 at 11:33 AM Zhuoyun Wei  wrote:
> > >> Hi,
> > >>
> > >>  the CSV importer determines the account to use by "regexps"
> parameter. I have two accounts from the same bank (one checking and one
> savings), and the CSV files of both are of the same format. There isn't
> anything in the file content that could tell the two accounts apart. The
> only difference is the file name (e.g. "Chase.csv" for checking,
> "Chase.csv" for savings).
> > >>
> > >>  Under this circumstance, "regexps" parameter does not work. How
> could I import different files into different accounts?
> > >>
> > >>  --
> > >>  Zhuoyun Wei
> > >>
> > >>  --
> > >>  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  beancount%2bunsubscr...@googlegroups.com>.
> > >>  To post to this group, send email to beancount@googlegroups.com.
> > >>  To view this discussion on the web visit
> https://groups.google.com/d/msgid/beancount/17beda3b-4862-44e8-b839-51aaf6d573f8%40www.fastmail.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 beancount+unsubscr...@googlegroups.com.
> >  To post to this group, send email to beancount@googlegroups.com.
> >  To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/beancount/CAOHSxbnuC06TGuyP9C2a_1dZM_znUYfHuJMhSRNqjPByHc%3D7Lw%40mail.gmail.com
> <
> https://groups.google.com/d/msgid/beancount/CAOHSxbnuC06TGuyP9C2a_1dZM_znUYfHuJMhSRNqjPByHc%3D7Lw%40mail.gmail.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 beancount+unsubscr...@googlegroups.com.
To post to this group, send email to beancount@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAOHSxb%3DUPwnXh7UDp8YGCaLfvRv2gHg_bLQpnM-d2L6NoUYrCw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.