[GNC] Fwd: Adding Transactions From Another Program

Hal Vaughan hal at hal.dance
Fri May 8 01:44:39 EDT 2020



> Begin forwarded message:
> 
> From: Hal Vaughan <hal at hal.dance>
> Subject: Re: [GNC] Adding Transactions From Another Program
> Date: May 8, 2020 at 1:42:28 AM EDT
> To: david whiting <dw at davidwhiting.me.uk>
> 
> I think that’s it!
> 
> First, a comment: I went on and installed Homebrew and things seemed to work - until I tried running pip.  Nope.  It looks for $PYENV_COMMAND_PATH and that’s null.  (Even after rebooting and using a new terminal.)  And people wonder why I hate those add-ons like that.
> 
> Okay, on topic - yes, this could work.  I got curious - is there a way I can do more to automate this?  For instance, run my Python script, have it parse the GC file, then create the QIF file, save it.  Then I thought, "It would be nice if it could get GC to import the new QIF file, then exit GC and delete the QIF file all one one shot.  I did some searching and found something that said to try "Gnucash help."  No "—" before the "help," but I tried it.  GC came up, but I tried typing "help" in the console again.  When I quit GC, I got this:
> 
> These shell commands are defined internally.  Type `help' to see this list.
> Type `help name' to find out more about the function `name'.
> Use `info bash' to find out more about the shell in general.
> Use `man -k' or `info' to find out more about commands not in this list.
> 
> A star (*) next to a name means that the command is disabled.
> 
> JOB_SPEC [&]                       (( expression ))
> . filename [arguments]             :
> [ arg... ]                         [[ expression ]]
> alias [-p] [name[=value] ... ]     bg [job_spec ...]
> bind [-lpvsPVS] [-m keymap] [-f fi break [n]
> builtin [shell-builtin [arg ...]]  caller [EXPR]
> case WORD in [PATTERN [| PATTERN]. cd [-L|-P] [dir]
> command [-pVv] command [arg ...]   compgen [-abcdefgjksuv] [-o option
> complete [-abcdefgjksuv] [-pr] [-o continue [n]
> declare [-afFirtx] [-p] [name[=val dirs [-clpv] [+N] [-N]
> disown [-h] [-ar] [jobspec ...]    echo [-neE] [arg ...]
> enable [-pnds] [-a] [-f filename]  eval [arg ...]
> exec [-cl] [-a name] file [redirec exit [n]
> export [-nf] [name[=value] ...] or false
> fc [-e ename] [-nlr] [first] [last fg [job_spec]
> for NAME [in WORDS ... ;] do COMMA for (( exp1; exp2; exp3 )); do COM
> function NAME { COMMANDS ; } or NA getopts optstring name [arg]
> hash [-lr] [-p pathname] [-dt] [na help [-s] [pattern ...]
> history [-c] [-d offset] [n] or hi if COMMANDS; then COMMANDS; [ elif
> jobs [-lnprs] [jobspec ...] or job kill [-s sigspec | -n signum | -si
> let arg [arg ...]                  local name[=value] ...
> logout                             popd [+N | -N] [-n]
> printf [-v var] format [arguments] pushd [dir | +N | -N] [-n]
> pwd [-LP]                          read [-ers] [-u fd] [-t timeout] [
> readonly [-af] [name[=value] ...]  return [n]
> select NAME [in WORDS ... ;] do CO set [--abefhkmnptuvxBCHP] [-o opti
> shift [n]                          shopt [-pqsu] [-o long-option] opt
> source filename [arguments]        suspend [-f]
> test [expr]                        time [-p] PIPELINE
> times                              trap [-lp] [arg signal_spec ...]
> true                               type [-afptP] name [name ...]
> typeset [-afFirtx] [-p] name[=valu ulimit [-SHacdfilmnpqstuvx] [limit
> umask [-p] [-S] [mode]             unalias [-a] name [name ...]
> unset [-f] [-v] [name ...]         until COMMANDS; do COMMANDS; done
> variables - Some variable names an wait [n]
> while COMMANDS; do COMMANDS; done  { COMMANDS ; }
> 
> I couldn’t fine anything on Gnu Bash, but this looks interesting.  I’ll address it in a separate thread, but I found the command line options were sparse, but this makes me wonder if there’s a way to run a batch file for GC and, in that batch file, tell it to import a QIF file.
> 
> Not necessary, but it would be nice, otherwise, it’s a multi-step process: Run my script, run GC, import, quit GC, delete QIF.  Doesn’t sound like much, but it can be a pain for a forgetful person like me.
> 
> 
> Hal
> 
>> 
>> On May 7, 2020, at 6:23 PM, david whiting <dw at davidwhiting.me.uk> wrote:
>> 
>> Hi Hal,
>> 
>> Looking back at your original question, perhaps there's an alternative
>> approach that will achieve what you want to do. Rater than using
>> python to add the entries directly, once your python script has found
>> the transactions, use that to write a qif file that specifies the
>> transactions you want and then import that file in gnucash. I do
>> something similar where I have to create monthly subs transactions
>> covering six months for about 450 club members, so about 2,700
>> transactions. The amount of the subs each member pays depends on the
>> team the member is in so the script that works out which team each
>> member is in, looks up the monthly amount in a separate look-up csv
>> file and then creates the qif file. I then import this into gnucash at
>> the beginning of the season (s the transactions have dates in the
>> future). The qif format is simple to create. This has worked nicely
>> for me.
>> 
>> David
>> 
>> On Thu, 7 May 2020 at 19:23, Hal Vaughan <hal at hal.dance> wrote:
>>> 
>>> It took me time to do some research on this.  (Even with staying at home now, I have a ton going on and had to spend several full days just fixing my tractor.)
>>> 
>>> Homebrew looked like it wasn’t much of a problem and I installed it.  Everything still works.  (That’s another part of research - I still have to go through the folder where all my scripts are and figure out which ones I still need that may be using oddball or outdated Perl or Python modules.  I have notes on a number of them that I use whenever I upgrade to a new computer, so that’ll help, but it’s still a time waster!)
>>> 
>>> So, ignoring the entertaining auto-correct issue here, if I use Homebrew, it just installs from a stock .dmg image.  So if I want Python bindings, Homebrew is irrelevant?  As in it doesn’t matter if I use it or not, I can just get the source code for GC and compile it on my system to get the bindings.  Is that right?
>>> 
>>> That leads to a number of questions:
>>> 1. I’m not inexperienced as a programmer, but it’s almost all with Perl, Python, and Java.  Years ago I did some C++, but have done very little in learning how to control compilers.  How hard is compiling GC from scratch?
>>> 2. If I compile from scratch, do I have to add anything extra to get Python bindings, or do I just have to select the option for that when I compile?
>>> 3.  What about upgrades?  Will I have to recompile GC every time I want to upgrade it on my system?  (That is, assuming I want to keep the bindings?)
>>> 
>>> From what people are saying, trying to add entries is not good, but that I can import from a CSV or TSV file.
>>> 
>>> While that was on another branch of this thread, that does bring up a few questions:
>>> 
>>> 1. Is there any protection to keep GC from importing the same transaction multiple times?  For instance, if I have a transaction for interest in a CSV file, then add another in the file and re-import, will GC note one transaction it’s importing is identical to another and flag it for me?
>>> 2. Is there any way, from within GC, to run an external script that would create the interest entries?  Then, once they’re created, I could import that CSV file?  Or would I have to run the interest calculating script from outside GC?
>>> 
>>> 
>>> Hal
>>> 
>>>> On Apr 30, 2020, at 11:51 PM, D. <sunfish62 at yahoo.com> wrote:
>>>> 
>>>> Hal,
>>>> 
>>>> John Ralls, the person who manages the Mac end of GnuCash, has pointed out that Homebrew simply uses the GnuCash dmg for its installation. That dmg does not include python bindings, so the answer to your question is "No, Homebrew does not include python. You would need to clozapine GnuCash yourself."
>>>> 
>>>> David T.
>>>> 
>>>> 
>>>> -------- Original Message --------
>>>> From: Hal Vaughan <hal at hal.dance>
>>>> Sent: Fri May 01 01:32:14 GMT+05:30 2020
>>>> To: Gnucash <gnucash-user at gnucash.org>
>>>> Subject: Re: [GNC] Adding Transactions From Another Program
>>>> 
>>>> Actually, this has me looking over what I am and am not still using.
>>>> 
>>>> Since Mac is still using Python 2.7, but Catalina is coming up and that includes Python 3.x.  So I’m looking over what I use and what I don’t among my decades of scripts.
>>>> 
>>>> Last I looked, pretty much every system like that usurped the originals.  At the time, when I looked them over, it became clear to me why they did that and it made sense.  But, again, that decision was something like 10 years ago and I haven’t had time or cause to revisit it - until now.
>>>> 
>>>> Do you know if Homebrew can provide the Python bindings for GC?
>>>> 
>>>> 
>>>> Hal
>>>> 
>>>>> On Apr 30, 2020, at 2:27 AM, Adrien Monteleone <adrien.monteleone at lusfiber.net> wrote:
>>>>> 
>>>>> Have you investigated Homebrew vs. MacPorts?
>>>>> 
>>>>> Just curious if the Perl issues are the same.
>>>>> 
>>>>> Regards,
>>>>> Adrien
>>>>> 
>>>>>> On Apr 30, 2020 w18d121, at 12:29 AM, Hal Vaughan <hal at hal.dance> wrote:
>>>>>> 
>>>>>> I’ve checked out the bindings - as I mentioned in my original post, the problem is that using the bindings on a Mac requires MacPorts.  I’ve had issues before, since MacPorts (and other similar systems) usurp some of the normal paths for things like Perl and Python.  I don’t use Perl for coding anymore, but I have Perl scripts I’ve been using for over a decade that do some simple work for me.  I had an important Perl script I was using that used a specific Perl library.  I don’t remember which one it was, but when I added MacPorts and tried to run my script a week later, it crashed.
>>>>>> 
>>>>>> I had no idea MacPorts, Fink, Homebrew, and similar systems usurped the normal system paths for scripting languages.  When I installed it, and it took over for Perl, it put in a system without all the libraries my scripts used and some of the libraries that were available to me with a standard Perl install (libraries I had installed from CPAN) would not install in the new system.  I had to completely remove MacPorts to get my old scripts to work.
>>>>>> 
>>>>>> I’d love to use MacPorts, since it makes a lot available to me that I can’t easily add now (unless I start using a Linux VM), but that experience taught me never to trust such a system.
>>>>>> 
>>>>>> I think it would be a lot easier for me to do this with Python bindings, but I still use older scripts for things I need to do once a month or once a year and I don’t want to risk breaking them again like they broke about a decade ago when I installed MacPorts.
>>>>>> 
>>>>>> 
>>>>>> Hal
>>>>> 
>>>>> 
>>>>> _______________________________________________
>>>>> gnucash-user mailing list
>>>>> gnucash-user at gnucash.org
>>>>> To update your subscription preferences or to unsubscribe:
>>>>> https://lists.gnucash.org/mailman/listinfo/gnucash-user
>>>>> If you are using Nabble or Gmane, please see https://wiki.gnucash.org/wiki/Mailing_Lists for more information.
>>>>> -----
>>>>> Please remember to CC this list on all your replies.
>>>>> You can do this by using Reply-To-List or Reply-All.
>>>>> 
>>>> 
>>>> _______________________________________________
>>>> gnucash-user mailing list
>>>> gnucash-user at gnucash.org
>>>> To update your subscription preferences or to unsubscribe:
>>>> https://lists.gnucash.org/mailman/listinfo/gnucash-user
>>>> If you are using Nabble or Gmane, please see https://wiki.gnucash.org/wiki/Mailing_Lists for more information.
>>>> -----
>>>> Please remember to CC this list on all your replies.
>>>> You can do this by using Reply-To-List or Reply-All.
>>>> 
>>>> 
>>> 
>>> _______________________________________________
>>> gnucash-user mailing list
>>> gnucash-user at gnucash.org
>>> To update your subscription preferences or to unsubscribe:
>>> https://lists.gnucash.org/mailman/listinfo/gnucash-user
>>> If you are using Nabble or Gmane, please see https://wiki.gnucash.org/wiki/Mailing_Lists for more information.
>>> -----
>>> Please remember to CC this list on all your replies.
>>> You can do this by using Reply-To-List or Reply-All.
>> 
>> 
>> 
>> -- 
>> David Whiting
>> 
> 



More information about the gnucash-user mailing list