[GNC] How to bulk import about 130 Securities entries?
Jim DeLaHunt
list+gnucash at jdlh.com
Sat Aug 13 21:28:22 EDT 2022
Hello, folks:
I am a long-time GnuCash user, and for all those years I have pretty
much not attempted to track my investments in GnuCash. But now I want to
start. My first goal is to import many years of past activity.
I have downloaded the transactions from my brokerage account as a CSV
file. The first thing I get out of this is the name and symbol of about
130 securities. I am wondering if there is a practical way to bulk
import these into GnuCash. That is, instead of visiting Tools --
Security Editor, and pressing the Add button 130 times, and filling out
the "New security" dialogue 130 times, is there a more efficient path?
Looking at the File… Import menu, I do not see an option to import
Securities. Looking at the documentation, wiki, and list archives, I
don't see a mention of this. Is there some bulk import mechanism I am
overlooking?
I took a look at the uncompressed XML contents of a new, simple .gnucash
book file. It appears that the data entered in the "New security"
dialogue gets stored as <gnc:commodity> entities. There appears to be a
pretty simple relationship between the fields of the dialogue and the
text within the <gnc:commodity> entity. The entities are stored in a
certain order, sorted by <cmdty:space> then <cmdty:id>. There is a
<gnc:count-data cd:type="commodity"> entity which seems to contain a
text count of the non-CURRENCY gnc:commodity entries.
This makes me wonder if I could transform my list of 130 security names
and symbols into <gnc:commodity> entities, and insert them into the
GnuCash XML of my book.
Are there complexities or pitfalls about this approach which I might be
overlooking? We can certainly stipulate that manipulating the XML
content directly is unsupported and risky, I must be careful and keep
backups, I might blow off my fingers, etc. For what it's worth, I
believe that I am pretty proficient with editing XML, processing CSV
files, and scripting manipulations of text data.
Once I have the securities added to the book, I then need to add the
appropriate child accounts to my brokerage accounts, each denominated in
the appropriate security type and symbol. It looks like that is
straightforward to do with a CSV of accounts in the correct format, and
the File… Import… Import Accounts from CSV… menu item. I have a few
child accounts which I entered from the UI which will serve as
examples. Is there any way in which this is more difficult than it looks?
Cheers,
—Jim "ADBE ALNIX AOL … VUG VWO ZTD81" DeLaHunt
More information about the gnucash-user
mailing list