You are here

Python bindings in GnuCash portable

8 posts / 0 new
Last post
David Lynch9
Offline
Last seen: 9 years 12 months ago
Joined: 2014-04-23 12:12
Python bindings in GnuCash portable

I am running GnuCash 2.6.3 portable on Windows Vista SP2.

I am trying to use python to input share prices (modifying http://wiki.gnucash.org/wiki/Stocks/get_prices ), because other methods don't work.

The list archives seem to indicate that python bindings for windows are problematic. However, the change log for GnuCash portable implies they are implemented.

I get the error message:

from gnucash import Session, Account, Split
ImportError: No module named gnucash

How do I get the code
from gnucash import Session, Account, Split
to work, please?

Wm ...
Offline
Last seen: 7 years 3 months ago
Joined: 2010-07-17 12:37
gnucash not compiled with python bindings

I think the error message is saying that gnucash has not been compiled with python bindings. What in the change log makes you think it was?

I have just seen your posting 22 Apr in gnc-user.

You don't say why the other methods don't work. Is it a perl issue?

Wm

David Lynch9
Offline
Last seen: 9 years 12 months ago
Joined: 2014-04-23 12:12
Many thanks for your reply

Many thanks for your reply ... comments interspersed:
>>>>>>>>>>>>>
What in the change log makes you think it was?
>>>>>>>>>>>>>>>>>>>>>
From the GnuCash portable change log at http://www.softpedia.com/progChangelog/GNU-Cash-Portable-Changelog-10877...
for example:
Bug #723051: Implement gncCustomerNextID in Python bindings.
>>>>>>>>>>>>>>>>>>>>>
You don't say why the other methods don't work. Is it a perl issue?
>>>>>>>>>>>>>>>>>>>>>
Finance::Quote appears not to be able to access the site from which I get my share quotes (I've had help from the GnuCash user list, but that has proved unsuccessful.)
I can get the quotes into a csv text file. And modifying http://wiki.gnucash.org/wiki/Stocks/get_prices seemed a hopeful way forward to get the quotes from the csv file into GnuCash.
I'm more familar with C, C++ and Python than Perl, but I'm willing to try modifying a Perl program if that's easiest. I'm unable to get started because my environment is not set up correctly: it's that I need help with.
>>>>>>>>>>>>>>>>>>>

David Lynch

John T. Haller
John T. Haller's picture
Offline
Last seen: 1 hour 48 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Not Our Change Log

That's not Gnucash Portable's change log. Never trust something random you read on a download site. It's likely Gnucash proper's change log and some of those notes may only have to do with the Linux build of Gnucash (which is the main supported build), not the Windows build which is quite different.

Sometimes, the impossible can become possible, if you're awesome!

Wm ...
Offline
Last seen: 7 years 3 months ago
Joined: 2010-07-17 12:37
suggest we split the problem in two

1) can we get your share quotes into gnc?
2) can we do it under gnc portable? (the answer to that will be yes, we just have to use the right portable perl)

let's do 1 first.

where are your quotes coming from and can you provide me a brief sample csv file with a desc of the fields

my thought is to use a very brief script (language unimportant) to convert your csv to a known format and and then use existing stuff after that

Wm

David Lynch9
Offline
Last seen: 9 years 12 months ago
Joined: 2014-04-23 12:12
Many thanks for your reply.

Many thanks for your reply.

I can download my portfolio from http://www.trustnet.com into a spreadsheet, output the spreadsheet as csv, and manipulate it using sed/awk to get the following (or anything similar):

2014/04/21,
NA92,56.51
FR44,1124
V407,105.5

Row 1 date of prices which follow.
Other rows:
Field 1: Citicode
Field 2: Price

There are 24 rows in all.

David Lynch

Wm ...
Offline
Last seen: 7 years 3 months ago
Joined: 2010-07-17 12:37
some things to thunk about

* I can see why gnc doesn't support trustnet and why there wasn't general enthusiasm on the gnc lists
* how often do you buy/sell?
* how often do you monitor your portfolio value? weekly? monthly?
* the q's above are to help you decide whether this isn't better done by hand if there are only 23 fund / price combos

-------------

* if you can do sed/awk you can do perl, no probs, they're the elderly relatives after all
* if you were going to use python to begin with that would have been a non-portable python, right? which one?
* do you have a perl of any flavour at the moment? if so which one and how attached to it are you? is it portable?
* were you even thinking about complete portability for this or were you just going to update when "at base" and a non portable python / perl was available? i.e. you need gnc (the accounts) to be portable but not the price updates which can wait until you get back to the office / home ?

--------------

let me know your thoughts, I'm going to see if there is general agreement about a portable perl direction (I see Strawberry mentioned) so I can write up a general case for portable gnc + finance_quote regardless of your specific issue; thanks for the prompt, though, I had just been hand rolling and presumed myself the only one interested till I saw your post

--------------

for a bit of homework (not compulsory but educational as you can obviously parse python/sed/awk) look in your
\GnuCashPortable\App\GnuCash\bin
directory for a file named
install-fq-mods.cmd # easy to read DOS batch / cmd file
and 4 perl scripts named
gnc-fq-* # no file extensions as *nix systems don't need 'em

you might want to start from gnc-fq-dump, not hard to read, promise, to get an idea of what massaging your data will need.

in gnc terms you have symbol, date, price but not much else. if you look at the manual entry of prices and compare it to the script you'll see some things are going to have to be guessed at.

Wm

Wm ...
Offline
Last seen: 7 years 3 months ago
Joined: 2010-07-17 12:37
GnuCash python bindings may be possible soon-ish, read on

I have just built GnuCash 2.6.99 (not a typo) from scratch, this is very recent progression, see gnucash-devel.

Point relevant here is that building with python bindings on Win is now a realistic possibility so you may be able to do your plan A.

Will let you know how I get on over the next day or two, may be the weekend / bank holiday Monday.

Wm

Log in or register to post comments