Python Script to Import Multiple Commodities

Robin Chattopadhyay robinraymn at gmail.com
Thu Mar 1 22:40:10 EST 2012


Hi-

I took the python script from the Gnucash wiki[1] and modified it to import
multiple commodities from a single csv file. (This is a perfect solution
for my 401(k) because none of the funds in my plan are publicly traded).

I've run the script in a mostly blank test file (no accounts, no
transactions, only commodities) and the script works fine. When I run it
against my production file, I get the following errors:

29 times (there are only 5 commodities in the csv file):
* 20:45:35  CRIT <GLib> g_date_get_julian: assertion `g_date_valid (d)'
failed
* 20:45:35  CRIT <GLib> g_date_new_julian: assertion `g_date_valid_julian
(j)' failed

3 times:
* 20:45:48  CRIT <GLib> g_hash_table_foreach: assertion `version ==
hash_table->version' failed

I'm guessing it's happening when the script gets to here:

# Clean up
session.save()
session.end()
session.destroy()
quit()


There doesn't seem to be anything wrong with the price data that was
inserted with the script, so I'm wondering if there's something wrong with
the production file that I haven't noticed previously.

I'm not sure where go to from here; I've attached both the script and the
csv file.

[1]http://wiki.gnucash.org/wiki/Stocks/get_prices
-------------- next part --------------
Investment Name,Share Price,Unit Price,Value Date
DOW JONES TARGET TODAY FUND,,$11.8670,03/01/2012
DOW JONES TARGET 2010 FUND,,$14.2628,03/01/2012
DOW JONES TARGET 2015 FUND,,$10.7369,03/01/2012
DOW JONES TARGET 2020 FUND,,$15.3557,03/01/2012
DOW JONES TARGET 2025 FUND,,$10.6285,03/01/2012
DOW JONES TARGET 2030 FUND,,$15.8792,03/01/2012
DOW JONES TARGET 2035 FUND,,$10.2426,03/01/2012
DOW JONES TARGET 2040 FUND,,$17.4253,03/01/2012
DOW JONES TARGET 2045 FUND,,$10.2035,03/01/2012
DOW JONES TARGET 2050 FUND,,$10.2495,03/01/2012
DOW JONES TARGET 2055 FUND,,$10.1430,03/01/2012
WELLS FARGO ADV. 100% TREASURY MMKT FUND,,$1.0001,03/01/2012
WELLS FARGO STABLE VALUE FUND,$51.60,,03/01/2012
U.S.  BOND INDEX FUND,$12.26,,03/01/2012
LARGE CAP VALUE FUND,,$13.0025,03/01/2012
S&P 500 INDEX FUND,,$13.5511,03/01/2012
LARGE CAP GROWTH FUND,,$13.6554,03/01/2012
S&P MID CAP INDEX FUND,$17.13,,03/01/2012
RUSSELL SMALL CAP INDEX,$14.48,,03/01/2012
SMALL CAP FUND,,$13.8878,03/01/2012
INTERNATIONAL INDEX FUND,$15.02,,03/01/2012
EUROPACIFIC GROWTH FUND,$39.83,,03/01/2012
EMERGING MARKETS EQUITY FUND,$16.86,,03/01/2012
NASDAQ 100 INDEX FUND,$15.68,,03/01/2012
WELLS FARGO ESOP FUND,$31.54,$31.1252,03/01/2012
WELLS FARGO Non-ESOP FUND,$31.54,$3.5928,03/01/2012
-------------- next part --------------
A non-text attachment was scrubbed...
Name: import-prices-multiple.py
Type: text/x-python
Size: 1835 bytes
Desc: not available
URL: <http://lists.gnucash.org/pipermail/gnucash-user/attachments/20120301/55ddccc5/attachment.py>


More information about the gnucash-user mailing list